ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
1 changed files with 145336 additions and 0 deletions
37
services/project-delivery/controller/mode_test.go
Normal file
37
services/project-delivery/controller/mode_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue