Index restore report action updates

This commit is contained in:
2026-12-02 21:50:22 +00:00
parent f7a7afe12f
commit f4a8488167
4 changed files with 41 additions and 21 deletions

View File

@@ -740,3 +740,20 @@ func TestExecuteRestoreInstallsOptionalPrerequisiteHistory(t *testing.T) {
root := artifacts.SessionWorkDirForCampaign(workspaceRoot, cfg.Session.Campaign, cfg.Session.SessionID)
mustReadEquals(t, filepath.Join(root, "inputs", "previous", "artifacts", "session_recap.md"), "optional history\n")
}
func TestRestoreReportUpdatesFirstDuplicateAndCountsUnmatched(t *testing.T) {
action := RestoreAction{Kind: RestoreActionDownload, LocalRelativePath: "inputs/a", RemoteKey: "remote/a"}
report, err := newRestoreReport(&RemoteCurrentState{}, &RestorePlan{Actions: []RestoreAction{action, action}}, RestorePlanOptions{})
if err != nil {
t.Fatal(err)
}
report.markDownloaded(action)
report.markFailed(RestoreAction{LocalRelativePath: "missing", RemoteKey: "missing"}, nil)
if report.Actions[0].Status != "downloaded" || report.Actions[1].Status != "planned_download" || report.Execution.Downloaded != 1 || report.Execution.Failed != 1 {
t.Fatalf("unexpected report: %+v", report)
}
data, err := json.Marshal(report)
if err != nil || strings.Contains(string(data), "actionIndices") {
t.Fatalf("serialized report = %s, error = %v", data, err)
}
}