Implement manifest model and local store
This commit is contained in:
66
internal/manifest/manifest_test.go
Normal file
66
internal/manifest/manifest_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package manifest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStageMarkHelpers(t *testing.T) {
|
||||
m := New("2026-05-03", time.Date(2026, 5, 3, 12, 0, 0, 0, time.UTC))
|
||||
|
||||
runningAt := time.Date(2026, 5, 3, 12, 1, 0, 0, time.UTC)
|
||||
m.MarkStageRunning("transcribe", runningAt)
|
||||
|
||||
stage := m.Stages["transcribe"]
|
||||
if stage == nil {
|
||||
t.Fatal("stage not created")
|
||||
}
|
||||
if stage.Status != StatusRunning {
|
||||
t.Fatalf("status = %q, want %q", stage.Status, StatusRunning)
|
||||
}
|
||||
if stage.StartedAt == nil || !stage.StartedAt.Equal(runningAt) {
|
||||
t.Fatalf("started_at = %v, want %v", stage.StartedAt, runningAt)
|
||||
}
|
||||
|
||||
succeededAt := runningAt.Add(2 * time.Minute)
|
||||
outputs := []ArtifactRecord{{Kind: "processed_transcript", LocalPath: "transcripts/processed.json"}}
|
||||
m.MarkStageSucceeded("transcribe", succeededAt, outputs)
|
||||
if stage.Status != StatusSucceeded {
|
||||
t.Fatalf("status = %q, want %q", stage.Status, StatusSucceeded)
|
||||
}
|
||||
if stage.CompletedAt == nil || !stage.CompletedAt.Equal(succeededAt) {
|
||||
t.Fatalf("completed_at = %v, want %v", stage.CompletedAt, succeededAt)
|
||||
}
|
||||
if len(stage.Outputs) != 1 {
|
||||
t.Fatalf("outputs len = %d, want 1", len(stage.Outputs))
|
||||
}
|
||||
|
||||
failedAt := succeededAt.Add(1 * time.Minute)
|
||||
m.MarkStageFailed("analyze", failedAt, "analyzer crashed")
|
||||
failed := m.Stages["analyze"]
|
||||
if failed == nil {
|
||||
t.Fatal("failed stage missing")
|
||||
}
|
||||
if failed.Status != StatusFailed {
|
||||
t.Fatalf("status = %q, want %q", failed.Status, StatusFailed)
|
||||
}
|
||||
if failed.Error == nil || failed.Error.Message != "analyzer crashed" {
|
||||
t.Fatalf("error = %#v, want message", failed.Error)
|
||||
}
|
||||
|
||||
skippedAt := failedAt.Add(1 * time.Minute)
|
||||
m.MarkStageSkipped("notify", skippedAt, "notifications disabled")
|
||||
skipped := m.Stages["notify"]
|
||||
if skipped == nil {
|
||||
t.Fatal("skipped stage missing")
|
||||
}
|
||||
if skipped.Status != StatusSkipped {
|
||||
t.Fatalf("status = %q, want %q", skipped.Status, StatusSkipped)
|
||||
}
|
||||
if skipped.Error == nil || skipped.Error.Message != "notifications disabled" {
|
||||
t.Fatalf("error = %#v, want skip reason", skipped.Error)
|
||||
}
|
||||
if skipped.Error.Code != "skipped" {
|
||||
t.Fatalf("error code = %q, want %q", skipped.Error.Code, "skipped")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user