Clear superseded session stage result details
This commit is contained in:
@@ -69,11 +69,12 @@ func TestStageMarkHelpers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkStageRunningClearsPriorCompletionAndError(t *testing.T) {
|
||||
func TestMarkStageRunningClearsPriorCompletionErrorAndResultDetails(t *testing.T) {
|
||||
m := New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
|
||||
|
||||
failedAt := time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC)
|
||||
m.MarkStageFailed("merge", failedAt, "boom")
|
||||
setStageResultDetails(m.Stages["merge"])
|
||||
|
||||
runAt := failedAt.Add(1 * time.Minute)
|
||||
m.MarkStageRunning("merge", runAt)
|
||||
@@ -91,6 +92,7 @@ func TestMarkStageRunningClearsPriorCompletionAndError(t *testing.T) {
|
||||
if stage.Error != nil {
|
||||
t.Fatalf("error = %#v, want nil while running", stage.Error)
|
||||
}
|
||||
requireStageResultDetailsCleared(t, stage)
|
||||
}
|
||||
|
||||
func TestMarkStageSucceededClearsError(t *testing.T) {
|
||||
@@ -111,11 +113,24 @@ func TestMarkStageSucceededClearsError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkStageSkippedClearsEarlierOutputs(t *testing.T) {
|
||||
func TestMarkStageFailedClearsEarlierResultDetails(t *testing.T) {
|
||||
m := New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
|
||||
m.MarkStageSucceeded("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), []ArtifactRecord{
|
||||
{Kind: "structured_data", SourceID: "narratio.example.characters", LocalPath: "artifacts/characters.json"},
|
||||
})
|
||||
m.MarkStageSucceeded("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
|
||||
setStageResultDetails(m.Stages["extract"])
|
||||
|
||||
m.MarkStageFailed("extract", time.Date(2026, 5, 3, 10, 2, 0, 0, time.UTC), "replacement failed")
|
||||
|
||||
stage := m.Stages["extract"]
|
||||
if stage == nil || stage.Status != StatusFailed {
|
||||
t.Fatalf("stage = %#v, want failed", stage)
|
||||
}
|
||||
requireStageResultDetailsCleared(t, stage)
|
||||
}
|
||||
|
||||
func TestMarkStageSkippedClearsEarlierResultDetails(t *testing.T) {
|
||||
m := New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
|
||||
m.MarkStageSucceeded("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
|
||||
setStageResultDetails(m.Stages["extract"])
|
||||
|
||||
m.MarkStageSkipped("extract", time.Date(2026, 5, 3, 10, 2, 0, 0, time.UTC), "integration_disabled")
|
||||
|
||||
@@ -126,7 +141,39 @@ func TestMarkStageSkippedClearsEarlierOutputs(t *testing.T) {
|
||||
if stage.Status != StatusSkipped {
|
||||
t.Fatalf("status = %q, want %q", stage.Status, StatusSkipped)
|
||||
}
|
||||
if len(stage.Outputs) != 0 {
|
||||
t.Fatalf("outputs = %#v, want cleared", stage.Outputs)
|
||||
requireStageResultDetailsCleared(t, stage)
|
||||
}
|
||||
|
||||
func TestMarkStageStalePreservesResultDetails(t *testing.T) {
|
||||
m := New("2026-05-03", time.Date(2026, 5, 3, 10, 0, 0, 0, time.UTC))
|
||||
m.MarkStageSucceeded("extract", time.Date(2026, 5, 3, 10, 1, 0, 0, time.UTC), nil)
|
||||
stage := m.Stages["extract"]
|
||||
setStageResultDetails(stage)
|
||||
|
||||
m.MarkStageStale("extract", time.Date(2026, 5, 3, 10, 2, 0, 0, time.UTC), "result is not resumable")
|
||||
|
||||
if stage.Status != StatusStale {
|
||||
t.Fatalf("status = %q, want %q", stage.Status, StatusStale)
|
||||
}
|
||||
if len(stage.Outputs) != 1 || len(stage.Logs) != 1 || len(stage.GeneratedConfigs) != 1 || len(stage.Metadata) != 1 {
|
||||
t.Fatalf("result details were not preserved: %#v", stage)
|
||||
}
|
||||
}
|
||||
|
||||
func setStageResultDetails(stage *StageRecord) {
|
||||
stage.Outputs = []ArtifactRecord{{
|
||||
Kind: "structured_data",
|
||||
SourceID: "narratio.example.characters",
|
||||
LocalPath: "artifacts/characters.json",
|
||||
}}
|
||||
stage.Logs = []string{"logs/extract.log"}
|
||||
stage.GeneratedConfigs = []string{"generated/extract.yaml"}
|
||||
stage.Metadata = map[string]any{"bundle_path": "extract/results/run-1"}
|
||||
}
|
||||
|
||||
func requireStageResultDetailsCleared(t *testing.T, stage *StageRecord) {
|
||||
t.Helper()
|
||||
if len(stage.Outputs) != 0 || len(stage.Logs) != 0 || len(stage.GeneratedConfigs) != 0 || len(stage.Metadata) != 0 {
|
||||
t.Fatalf("result details were not cleared: %#v", stage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user