Prepare resolved documents and autocorrection rules

This commit is contained in:
2026-11-30 00:31:36 +00:00
parent 5c4ca20b11
commit 4e94b2157b
22 changed files with 197 additions and 335 deletions

View File

@@ -13,10 +13,10 @@ import (
)
func TestResolvePreparedInputReturnsVerifiedIdentity(t *testing.T) {
paths, m, canonicalPath, checksum := preparedInputFixture(t, artifactpolicy.SourceInputSpellCatalog, []byte("{\"spells\":[]}\n"))
m.Inputs[0].Path = filepath.ToSlash(filepath.Join("inputs", "spell_catalog.json"))
paths, m, canonicalPath, checksum := preparedInputFixture(t, artifactpolicy.SourceInputParty, []byte("{\"spells\":[]}\n"))
m.Inputs[0].Path = filepath.ToSlash(filepath.Join("inputs", "party.yml"))
identity, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputSpellCatalog)
identity, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputParty)
if err != nil {
t.Fatalf("ResolvePreparedInput() error = %v", err)
}
@@ -24,10 +24,10 @@ func TestResolvePreparedInputReturnsVerifiedIdentity(t *testing.T) {
if err != nil {
t.Fatalf("filepath.Abs() error = %v", err)
}
if identity.SourceID != artifactpolicy.SourceInputSpellCatalog ||
identity.ManifestKind != "spell_catalog" ||
if identity.SourceID != artifactpolicy.SourceInputParty ||
identity.ManifestKind != "party" ||
identity.Path != wantAbsolute ||
identity.RelativePath != "inputs/spell_catalog.json" ||
identity.RelativePath != "inputs/party.yml" ||
identity.Checksum != checksum ||
identity.Size != int64(len("{\"spells\":[]}\n")) {
t.Fatalf("ResolvePreparedInput() = %#v", identity)
@@ -105,9 +105,9 @@ func TestResolvePreparedInputRejectsInvalidManifestEvidence(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
paths, m, canonicalPath, _ := preparedInputFixture(t, artifactpolicy.SourceInputSpellCatalog, []byte("{\"spells\":[]}\n"))
paths, m, canonicalPath, _ := preparedInputFixture(t, artifactpolicy.SourceInputParty, []byte("{\"spells\":[]}\n"))
tt.mutate(t, paths, m, canonicalPath)
_, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputSpellCatalog)
_, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputParty)
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
t.Fatalf("ResolvePreparedInput() error = %v, want containing %q", err, tt.wantErr)
}
@@ -155,9 +155,9 @@ func TestResolvePreparedInputRejectsInvalidCanonicalFile(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
paths, m, canonicalPath, _ := preparedInputFixture(t, artifactpolicy.SourceInputSpellCatalog, []byte("{\"spells\":[]}\n"))
paths, m, canonicalPath, _ := preparedInputFixture(t, artifactpolicy.SourceInputParty, []byte("{\"spells\":[]}\n"))
tt.mutate(t, canonicalPath)
_, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputSpellCatalog)
_, err := ResolvePreparedInput(paths, m, artifactpolicy.SourceInputParty)
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
t.Fatalf("ResolvePreparedInput() error = %v, want containing %q", err, tt.wantErr)
}