37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
)
|
|
|
|
func TestOldModeCompletes(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{values: map[string]string{"refs/heads/main": revision}}, &now)
|
|
instance.reconcileAll(ctx)
|
|
workflow := workflowName("build", "11111111-2222-3333-4444-555555555555", "", revision)
|
|
setNamedWorkflowStatus(t, instance, workflow, "Succeeded", nil)
|
|
object := getDelivery(t, instance, "point")
|
|
unstructured.RemoveNestedField(object.Object, "spec", "source", "point")
|
|
if err := unstructured.SetNestedMap(object.Object, map[string]any{"ref": "refs/heads/main"}, "spec", "source", "continuous"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := instance.client.Resource(projectDeliveryGVR).Namespace("delivery").Update(ctx, object, metav1.UpdateOptions{}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
instance.reconcileAll(ctx)
|
|
object = getDelivery(t, instance, "point")
|
|
points, _, err := unstructured.NestedSlice(object.Object, "status", "points")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if phase := points[0].(map[string]any)["phase"]; phase != "Succeeded" {
|
|
t.Fatalf("old Point attempt remains %v after its Workflow succeeded", phase)
|
|
}
|
|
}
|