Index product paths once during restore planning
This commit is contained in:
35
internal/app/restore_product_paths_test.go
Normal file
35
internal/app/restore_product_paths_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user