Plan imports from published product inventories

This commit is contained in:
2026-12-02 16:02:48 +00:00
parent 4f50a57a38
commit ad8a5df97b
9 changed files with 414 additions and 37 deletions

View File

@@ -39,7 +39,7 @@ func TestExecuteRestoreHelp(t *testing.T) {
func TestExecuteRestoreDryRunPrintsPlanWithoutWriting(t *testing.T) {
deps := restoreCommandDependencies(&storage.FakeBackend{})
deps.discoverRemoteCurrentState = func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error) {
deps.discoverRemotePublication = func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error) {
return &RemoteCurrentState{
SessionID: "2026-05-03",
Campaign: "sample-campaign",
@@ -47,13 +47,13 @@ func TestExecuteRestoreDryRunPrintsPlanWithoutWriting(t *testing.T) {
ManifestData: restoreManifestJSON(t, "2026-05-03", "sample-campaign"),
}, nil
}
deps.buildRestorePlan = func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error) {
deps.buildInventoryRestorePlan = func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error) {
return &RestorePlan{
Actions: []RestoreAction{
{
Kind: RestoreActionDownload,
LocalRelativePath: "manifest.json",
RemoteKey: "dnd/campaigns/sample-campaign/sessions/2026-05-03/runs/20260519T010203Z-a1b2c3d4/session-manifest.json",
LocalRelativePath: "transcripts/final.json",
RemoteKey: "dnd/campaigns/sample-campaign/sessions/2026-05-03/runs/20260519T010203Z-a1b2c3d4/published/transcripts/final.json",
Reason: "local file missing",
},
},
@@ -88,7 +88,7 @@ func TestExecuteRestoreDryRunPrintsPlanWithoutWriting(t *testing.T) {
t.Fatalf("stderr = %q, want empty", stderr.String())
}
public := decodeRestoreCommandReport(t, stdout.Bytes())
if !public.DryRun || public.Complete || len(public.Actions) != 1 || public.Actions[0].LocalPath != "manifest.json" {
if !public.DryRun || public.Complete || len(public.Actions) != 1 || public.Actions[0].LocalPath != "transcripts/final.json" {
t.Fatalf("dry-run report=%#v", public)
}
@@ -187,7 +187,7 @@ func TestExecuteRestoreLoadsSecretsBeforeObjectStoreInit(t *testing.T) {
}
return &storage.FakeBackend{}, nil
}}
deps.discoverRemoteCurrentState = func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error) {
deps.discoverRemotePublication = func(context.Context, *config.Config, storage.ObjectStore) (*RemoteCurrentState, error) {
return &RemoteCurrentState{
SessionID: "2026-05-03",
Campaign: "sample-campaign",
@@ -195,13 +195,13 @@ func TestExecuteRestoreLoadsSecretsBeforeObjectStoreInit(t *testing.T) {
ManifestData: restoreManifestJSON(t, "2026-05-03", "sample-campaign"),
}, nil
}
deps.buildRestorePlan = func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error) {
deps.buildInventoryRestorePlan = func(context.Context, *config.Config, *RemoteCurrentState, storage.ObjectStore, RestorePlanOptions) (*RestorePlan, error) {
return &RestorePlan{
Actions: []RestoreAction{
{
Kind: RestoreActionDownload,
LocalRelativePath: "manifest.json",
RemoteKey: "dnd/campaigns/sample-campaign/sessions/2026-05-03/runs/20260519T010203Z-a1b2c3d4/session-manifest.json",
LocalRelativePath: "transcripts/final.json",
RemoteKey: "dnd/campaigns/sample-campaign/sessions/2026-05-03/runs/20260519T010203Z-a1b2c3d4/published/transcripts/final.json",
Reason: "local file missing",
},
},