package app import ( "testing" "gitea.maximumdirect.net/eric/narratio/internal/manifest" ) func TestRestoreProductPathsRetainsAgreementChecks(t *testing.T) { cfg := restorePlanConfig(t) const source = "narratio.artifact.session_recap" for _, conflicting := range []bool{false, true} { m := &manifest.Manifest{Stages: map[string]*manifest.StageRecord{ "analyze": {Outputs: []manifest.ArtifactRecord{{SourceID: source, LocalPath: "artifacts/session_recap.md"}}, AnalyzeArtifacts: map[string]manifest.AnalyzeArtifactRecord{ "session_recap": {Output: &manifest.ArtifactRecord{SourceID: source, LocalPath: "artifacts/session_recap.md"}}, }}, "other": {Outputs: []manifest.ArtifactRecord{{SourceID: "unselected", LocalPath: "../outside"}}}, }} if conflicting { m.Stages["analyze"].AnalyzeArtifacts["session_recap"].Output.LocalPath = "artifacts/other.md" } index := newRestoreProductPaths(m) path, err := index.relativePath(cfg, m, t.TempDir(), source) if conflicting && err == nil { t.Fatal("conflicting evidence accepted") } if !conflicting && (err != nil || path != "artifacts/session_recap.md") { t.Fatalf("agreeing evidence: %q, %v", path, err) } if _, err := index.relativePath(cfg, m, t.TempDir(), "unselected"); err == nil { t.Fatal("requested unsafe evidence accepted") } } }