package main import ( "context" "testing" "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) func TestCollectedAttempt(t *testing.T) { ctx := context.Background() now := time.Date(2026, 10, 2, 0, 0, 0, 0, time.UTC) revision := "0123456789abcdef0123456789abcdef01234567" instance := testController(t, pointDelivery(revision), &mutableRefs{}, &now) instance.reconcileAll(ctx) name := workflowName("build", "11111111-2222-3333-4444-555555555555", "", revision) setNamedWorkflowStatus(t, instance, name, "Running", nil) instance.reconcileAll(ctx) setNamedWorkflowStatus(t, instance, name, "Succeeded", nil) if err := instance.client.Resource(workflowGVR).Namespace("delivery").Delete(ctx, name, metav1.DeleteOptions{}); err != nil { t.Fatal(err) } instance.reconcileAll(ctx) instance.reconcileAll(ctx) if count := countWorkflows(t, instance, "build"); count != 0 { t.Fatalf("collected execution was resubmitted: %d Workflows", count) } points, _, err := unstructured.NestedSlice(getDelivery(t, instance, "point").Object, "status", "points") if err != nil { t.Fatal(err) } if phase := points[0].(map[string]any)["phase"].(string); !terminalPhase(phase) { t.Fatalf("collected attempt remains %s", phase) } }