package api import ( "droboticflow/internal/domain" "testing" ) func TestCapturePartReprocessPreservesSelectedFiles(t *testing.T) { workflow := &domain.WorkflowRecord{CaptureAutomation: &domain.CaptureAutomationConfig{ConnectionID: "connection", Bucket: "bucket", WorkflowInputID: "sourceDirectory"}, WorkflowInputs: []domain.WorkflowInputDefinition{{ID: "sourceDirectory", Type: domain.PortTypeFile}}} record := &domain.CaptureRecord{Prefix: "incoming/capture/part0001", SourcePrefix: "incoming/capture", CaptureID: "capture/part0001", SourceKeys: []string{"incoming/capture/part0001/left.mp4", "incoming/capture/calibration_camera.yaml"}, Fingerprint: "snapshot"} inputs, err := captureReprocessInput(workflow, record) if err != nil { t.Fatal(err) } ref := inputs["sourceDirectory"].Ref if ref.Prefix != record.SourcePrefix || ref.CaptureUnit != record.CaptureID || len(ref.ObjectKeys) != 2 { t.Fatalf("selection lost during retry: %+v", ref) } record.SourceKeys[0] = "changed" if ref.ObjectKeys[0] == "changed" { t.Fatal("retry input aliases mutable record") } }