Skip to content

Commit ab0732d

Browse files
committed
add test for purpose override
1 parent 9d4afb9 commit ab0732d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

internal/controllers/managedcontrolplane/controller_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,4 +599,24 @@ var _ = Describe("ManagedControlPlane Controller", func() {
599599
Expect(env.Client(platform).Get(env.Ctx, client.ObjectKeyFromObject(cr), cr)).To(MatchError(apierrors.IsNotFound, "IsNotFound"))
600600
})
601601

602+
It("should correctly set the purpose if the MCP has the override label", func() {
603+
rec, env := defaultTestSetup("testdata", "test-01")
604+
605+
mcp := &corev2alpha1.ManagedControlPlaneV2{}
606+
mcp.SetName("mcp-02")
607+
mcp.SetNamespace("test")
608+
Expect(env.Client(onboarding).Get(env.Ctx, client.ObjectKeyFromObject(mcp), mcp)).To(Succeed())
609+
610+
platformNamespace, err := libutils.StableMCPNamespace(mcp.Name, mcp.Namespace)
611+
Expect(err).ToNot(HaveOccurred())
612+
env.ShouldReconcile(mcpRec, testutils.RequestFromObject(mcp))
613+
cr := &clustersv1alpha1.ClusterRequest{}
614+
cr.SetName(mcp.Name)
615+
cr.SetNamespace(platformNamespace)
616+
Expect(env.Client(platform).Get(env.Ctx, client.ObjectKeyFromObject(cr), cr)).To(Succeed())
617+
Expect(cr.Spec.Purpose).ToNot(Equal(rec.Config.MCPClusterPurpose))
618+
Expect(cr.Spec.Purpose).To(Equal("my-mcp-purpose"))
619+
Expect(cr.Spec.WaitForClusterDeletion).To(PointTo(BeTrue()))
620+
})
621+
602622
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: core.openmcp.cloud/v2alpha1
2+
kind: ManagedControlPlaneV2
3+
metadata:
4+
name: mcp-02
5+
namespace: test
6+
labels:
7+
core.openmcp.cloud/purpose: my-mcp-purpose
8+
spec: {}

0 commit comments

Comments
 (0)