Merge imported products into local session state
This commit is contained in:
@@ -18,26 +18,26 @@ func TestRestorePlanDefaultScope(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"transcripts/full.json", []byte(`{"segments":[1]}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"transcripts/final.trimmed.json", []byte(`{"segments":[1]}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"artifacts/session_recap.md", []byte("# recap\n"))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"audio/alice.flac", []byte("audio"))
|
||||
seedRestoreObject(store, current.SessionPrefix+"runs/20260519T010203Z-a1b2/manifest.json", []byte("{}"))
|
||||
seedRestoreObject(store, current.SessionPrefix+"logs/publish.log", []byte("log"))
|
||||
seedRestoreObject(store, current.SessionPrefix+"cache/notarius/references/ignored/party.yml", []byte("cache"))
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
got := actionRelPaths(plan.Actions)
|
||||
want := []string{"artifacts/session_recap.md", "manifest.json", "transcripts/full.json"}
|
||||
want := []string{"artifacts/session_recap.md", "transcripts/final.trimmed.json"}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("action local paths = %#v, want %#v", got, want)
|
||||
}
|
||||
if plan.DownloadCount != 3 || plan.SkipSameCount != 0 || plan.ConflictCount != 0 {
|
||||
t.Fatalf("counts = download=%d skip_same=%d conflict=%d, want 3/0/0", plan.DownloadCount, plan.SkipSameCount, plan.ConflictCount)
|
||||
if plan.DownloadCount != 2 || plan.SkipSameCount != 0 || plan.ConflictCount != 0 {
|
||||
t.Fatalf("counts = download=%d skip_same=%d conflict=%d, want 2/0/0", plan.DownloadCount, plan.SkipSameCount, plan.ConflictCount)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ func TestRestorePlanMapsNestedPublishedDestinationToFlatProduct(t *testing.T) {
|
||||
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(current.SessionPrefix, current.RunID), "published/custom/nested/recap.md")
|
||||
store.SeedObject(storage.FakeObject{Key: key, Data: []byte("recap")})
|
||||
item.DestinationKey, item.Generation = key, store.Objects[key].ETag
|
||||
item.Source = artifacts.ConfiguredArtifactSourceID("session_recap")
|
||||
}
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -82,15 +83,15 @@ func TestRestorePlanIncludeAudio(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"audio/alice.flac", []byte("audio"))
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
got := actionRelPaths(plan.Actions)
|
||||
want := []string{"audio/alice.flac", "manifest.json"}
|
||||
want := []string{"audio/alice.flac"}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("action local paths = %#v, want %#v", got, want)
|
||||
}
|
||||
@@ -101,14 +102,14 @@ func TestRestorePlanExistingAudioRequiresVerifiedReplacement(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"audio/alice.flac", []byte("audio"))
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "audio", "alice.flac"), "local")
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
for _, read := range store.Reads {
|
||||
if read.Key == current.SessionPrefix+"audio/alice.flac" {
|
||||
@@ -124,9 +125,9 @@ func TestRestorePlanExistingAudioRequiresVerifiedReplacement(t *testing.T) {
|
||||
t.Fatalf("audio action kind = %q, want %q", audioAction.Kind, RestoreActionConflict)
|
||||
}
|
||||
|
||||
forcedPlan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true, Force: true})
|
||||
forcedPlan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true, Force: true})
|
||||
if err != nil {
|
||||
t.Fatalf("forced buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("forced buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
for _, action := range forcedPlan.Actions {
|
||||
if action.LocalRelativePath == "audio/alice.flac" && action.Kind != RestoreActionDownload {
|
||||
@@ -141,16 +142,16 @@ func TestRestorePlanIncludesPreviousCacheByDefault(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestorePreviousCurrent(t, store, cfg, "# previous recap\n")
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
got := actionRelPaths(plan.Actions)
|
||||
want := []string{"inputs/previous/artifacts/session_recap.md", "manifest.json"}
|
||||
want := []string{"inputs/previous/artifacts/session_recap.md"}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("action local paths = %#v, want %#v", got, want)
|
||||
}
|
||||
@@ -161,17 +162,17 @@ func TestRestorePlanIgnoresCurrentSessionArchivedPreviousCache(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestoreObject(store, current.SessionPrefix+"previous/manifest.json", []byte(`{"session_id":"2026-04-26"}`))
|
||||
seedRestoreObject(store, current.SessionPrefix+"previous/artifacts/session_recap.md", []byte("# previous recap\n"))
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
got := actionRelPaths(plan.Actions)
|
||||
want := []string{"manifest.json"}
|
||||
want := []string{}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("action local paths = %#v, want %#v", got, want)
|
||||
}
|
||||
@@ -183,16 +184,16 @@ func TestRestorePlanMissingOptionalPreviousCacheSkipsArtifact(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestorePreviousCurrentManifestOnly(t, store, cfg)
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
got := actionRelPaths(plan.Actions)
|
||||
want := []string{"manifest.json"}
|
||||
want := []string{}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("action local paths = %#v, want %#v", got, want)
|
||||
}
|
||||
@@ -204,12 +205,12 @@ func TestRestorePlanMissingRequiredPreviousCacheFails(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestorePreviousCurrentManifestOnly(t, store, cfg)
|
||||
|
||||
_, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
_, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err == nil || !strings.Contains(err.Error(), "required previous-session artifact") {
|
||||
t.Fatalf("buildRestorePlan() error = %v, want required previous artifact failure", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v, want required previous artifact failure", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,22 +220,22 @@ func TestRestorePlanPreviousCacheConflictRequiresForce(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestorePreviousCurrent(t, store, cfg, "# remote previous recap\n")
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md"), "# local previous recap\n")
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
if plan.ConflictCount != 1 {
|
||||
t.Fatalf("ConflictCount = %d, want 1", plan.ConflictCount)
|
||||
}
|
||||
|
||||
plan, err = buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{Force: true})
|
||||
plan, err = buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{Force: true})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan(force) error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan(force) error = %v", err)
|
||||
}
|
||||
if plan.ConflictCount != 0 {
|
||||
t.Fatalf("force ConflictCount = %d, want 0", plan.ConflictCount)
|
||||
@@ -246,17 +247,17 @@ func TestRestorePlanClassifiesSameAndConflict(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"transcripts/full.json", []byte(`{"segments":[1]}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"transcripts/final.trimmed.json", []byte(`{"segments":[1]}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"artifacts/session_recap.md", []byte("remote-content\n"))
|
||||
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "transcripts", "full.json"), `{"segments":[1]}`)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "transcripts", "final.trimmed.json"), `{"segments":[1]}`)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "artifacts", "session_recap.md"), "different\n")
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
if plan.SkipSameCount != 1 {
|
||||
@@ -270,8 +271,8 @@ func TestRestorePlanClassifiesSameAndConflict(t *testing.T) {
|
||||
for _, action := range plan.Actions {
|
||||
actionByRel[action.LocalRelativePath] = action
|
||||
}
|
||||
if actionByRel["transcripts/full.json"].Kind != RestoreActionSkipSame {
|
||||
t.Fatalf("transcripts/full.json kind = %q, want %q", actionByRel["transcripts/full.json"].Kind, RestoreActionSkipSame)
|
||||
if actionByRel["transcripts/final.trimmed.json"].Kind != RestoreActionSkipSame {
|
||||
t.Fatalf("transcripts/full.json kind = %q, want %q", actionByRel["transcripts/final.trimmed.json"].Kind, RestoreActionSkipSame)
|
||||
}
|
||||
if actionByRel["artifacts/session_recap.md"].Kind != RestoreActionConflict {
|
||||
t.Fatalf("artifacts/session_recap.md kind = %q, want %q", actionByRel["artifacts/session_recap.md"].Kind, RestoreActionConflict)
|
||||
@@ -283,15 +284,15 @@ func TestRestorePlanForceTurnsConflictsIntoDownloads(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"artifacts/session_recap.md", []byte("remote-content\n"))
|
||||
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
mustWriteTestFile(t, filepath.Join(sessionRoot, "artifacts", "session_recap.md"), "different\n")
|
||||
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{Force: true})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{Force: true})
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan() error = %v", err)
|
||||
t.Fatalf("buildInventoryRestorePlan() error = %v", err)
|
||||
}
|
||||
|
||||
actionByRel := map[string]RestoreAction{}
|
||||
@@ -342,15 +343,15 @@ func TestRestorePlanSymlinksRemainNonRegularConflicts(t *testing.T) {
|
||||
cfg := restorePlanConfig(t)
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"artifacts/session_recap.md", []byte("remote-content\n"))
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
tt.setup(t, sessionRoot)
|
||||
|
||||
for _, options := range []RestorePlanOptions{{DryRun: true}, {Force: true}} {
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, options)
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, options)
|
||||
if err != nil {
|
||||
t.Fatalf("buildRestorePlan(%+v) error = %v", options, err)
|
||||
t.Fatalf("buildInventoryRestorePlan(%+v) error = %v", options, err)
|
||||
}
|
||||
action := restoreActionForPath(t, plan, "artifacts/session_recap.md")
|
||||
if action.Kind != RestoreActionConflict || action.ConflictKind != RestoreConflictNonRegular {
|
||||
@@ -377,10 +378,10 @@ func TestRestorePlanTraversalUnsafeKeyFails(t *testing.T) {
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, current.SessionPrefix+"artifacts/../../escape.txt", []byte("bad"))
|
||||
|
||||
_, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
_, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
@@ -394,11 +395,16 @@ func seedCurrentRestoreObject(t *testing.T, store *storage.FakeBackend, current
|
||||
artifactType := artifacts.RemoteArtifactTypePublishedOutput
|
||||
sourceKey := strings.NewReplacer("/", "_", ".", "_", "-", "_").Replace(strings.TrimPrefix(key, current.SessionPrefix))
|
||||
source := artifacts.ConfiguredArtifactSourceID(sourceKey)
|
||||
if strings.HasSuffix(key, "/transcripts/final.trimmed.json") {
|
||||
source = artifacts.ArtifactTranscriptFinalTrimmed
|
||||
}
|
||||
if strings.HasSuffix(key, "/artifacts/session_recap.md") {
|
||||
source = artifacts.ConfiguredArtifactSourceID("session_recap")
|
||||
}
|
||||
destination := key
|
||||
if key == current.CurrentManifestKey {
|
||||
if key == artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID) {
|
||||
artifactType = artifacts.RemoteArtifactTypeSessionManifest
|
||||
source = "session.manifest"
|
||||
current.ManifestData = append([]byte(nil), data...)
|
||||
} else if strings.HasPrefix(key, current.SessionPrefix) {
|
||||
destination = artifacts.S3RunPrefix(current.SessionPrefix, current.RunID) + "published/" + strings.TrimPrefix(key, current.SessionPrefix)
|
||||
}
|
||||
@@ -500,6 +506,7 @@ func restorePlanConfig(t *testing.T) *config.Config {
|
||||
RootPrefix: "dnd",
|
||||
}},
|
||||
},
|
||||
ArtifactCatalog: &config.ArtifactCatalog{Artifacts: map[string]config.ScriptoriumArtifactConfig{"session_recap": {Enabled: true, OutputPath: "artifacts/session_recap.md"}}},
|
||||
Session: &config.SessionConfig{
|
||||
SessionID: "2026-05-03",
|
||||
Campaign: "sample-campaign",
|
||||
@@ -533,12 +540,11 @@ func restorePlanCurrentState(t *testing.T, cfg *config.Config) *RemoteCurrentSta
|
||||
t.Helper()
|
||||
sessionPrefix := artifacts.S3SessionPrefix("dnd", cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
return &RemoteCurrentState{
|
||||
Bucket: "test-bucket",
|
||||
SessionPrefix: sessionPrefix,
|
||||
CurrentManifestKey: artifacts.S3RunSessionManifestKey(sessionPrefix, "20260519T010203Z-a1b2c3d4"),
|
||||
RunID: "20260519T010203Z-a1b2c3d4",
|
||||
SessionID: cfg.Session.SessionID,
|
||||
Campaign: cfg.Session.Campaign,
|
||||
Bucket: "test-bucket",
|
||||
SessionPrefix: sessionPrefix,
|
||||
RunID: "20260519T010203Z-a1b2c3d4",
|
||||
SessionID: cfg.Session.SessionID,
|
||||
Campaign: cfg.Session.Campaign,
|
||||
Commit: &artifacts.RemoteCommitManifest{
|
||||
FormatVersion: artifacts.RemoteCommitFormatVersion,
|
||||
Campaign: cfg.Session.Campaign,
|
||||
@@ -553,13 +559,13 @@ func TestRestorePlanIncludesAvailableOptionalPrerequisiteHistory(t *testing.T) {
|
||||
configureRestorePlanPreviousRequirement(cfg, false)
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
seedCurrentRestoreObject(t, store, current, current.CurrentManifestKey, []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedCurrentRestoreObject(t, store, current, artifacts.S3RunSessionManifestKey(current.SessionPrefix, current.RunID), []byte(`{"session_id":"2026-05-03"}`))
|
||||
seedRestorePreviousCurrent(t, store, cfg, "optional history\n")
|
||||
plan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
plan, err := buildInventoryRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []string{"inputs/previous/artifacts/session_recap.md", "manifest.json"}
|
||||
want := []string{"inputs/previous/artifacts/session_recap.md"}
|
||||
if got := actionRelPaths(plan.Actions); !slices.Equal(got, want) {
|
||||
t.Fatalf("actions = %v, want %v", got, want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user