droboticflow/internal/api/capture_attempt_test.go

21 lines
794 B
Go

package api
import (
"context"
"droboticflow/internal/domain"
"droboticflow/internal/store"
"testing"
)
func TestCaptureAttemptExcludesPackagingChild(t *testing.T) {
ctx := context.Background()
s := store.NewMemoryStore()
s.UpsertRun(ctx, domain.RunRecord{ID: "parent", WorkflowID: "wf", TaskID: "cap", Attempt: 2, CreatedAt: "2026-01-01"})
s.UpsertRun(ctx, domain.RunRecord{ID: "child", WorkflowID: "wf", TaskID: "cap", Attempt: 3, Trigger: domain.RunTriggerHumanRelease, ParentRunID: "parent", CreatedAt: "2026-01-02"})
server := &server{store: s}
got := server.captureAutomationPayload(ctx, &domain.WorkflowRecord{ID: "wf"}, []domain.CaptureRecord{{ID: "cap", RunID: "child"}})
if got.Records[0].Attempt != 2 {
t.Fatalf("packaging counted as retry: %#v", got.Records[0])
}
}