Skip to content

Commit 62b7448

Browse files
committed
Add test cases
1 parent af1823a commit 62b7448

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

exp/internal/controllers/machinepool_controller_phases_test.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func TestReconcileMachinePoolBootstrap(t *testing.T) {
605605
expectError: true,
606606
},
607607
{
608-
name: "existing machinepool, bootstrap data should not change",
608+
name: "existing machinepool with config ref, update data secret name",
609609
bootstrapConfig: map[string]interface{}{
610610
"kind": builder.TestBootstrapConfigKind,
611611
"apiVersion": builder.BootstrapGroupVersion.String(),
@@ -643,6 +643,45 @@ func TestReconcileMachinePoolBootstrap(t *testing.T) {
643643
},
644644
},
645645
expectError: false,
646+
expected: func(g *WithT, m *expv1.MachinePool) {
647+
g.Expect(m.Status.BootstrapReady).To(BeTrue())
648+
g.Expect(*m.Spec.Template.Spec.Bootstrap.DataSecretName).To(Equal("secret-data"))
649+
},
650+
},
651+
{
652+
name: "existing machinepool without config ref, do not update data secret name",
653+
bootstrapConfig: map[string]interface{}{
654+
"kind": builder.TestBootstrapConfigKind,
655+
"apiVersion": builder.BootstrapGroupVersion.String(),
656+
"metadata": map[string]interface{}{
657+
"name": "bootstrap-config1",
658+
"namespace": metav1.NamespaceDefault,
659+
},
660+
"spec": map[string]interface{}{},
661+
"status": map[string]interface{}{
662+
"ready": true,
663+
"dataSecretName": "secret-data",
664+
},
665+
},
666+
machinepool: &expv1.MachinePool{
667+
ObjectMeta: metav1.ObjectMeta{
668+
Name: "bootstrap-test-existing",
669+
Namespace: metav1.NamespaceDefault,
670+
},
671+
Spec: expv1.MachinePoolSpec{
672+
Template: clusterv1.MachineTemplateSpec{
673+
Spec: clusterv1.MachineSpec{
674+
Bootstrap: clusterv1.Bootstrap{
675+
DataSecretName: pointer.String("data"),
676+
},
677+
},
678+
},
679+
},
680+
Status: expv1.MachinePoolStatus{
681+
BootstrapReady: true,
682+
},
683+
},
684+
expectError: false,
646685
expected: func(g *WithT, m *expv1.MachinePool) {
647686
g.Expect(m.Status.BootstrapReady).To(BeTrue())
648687
g.Expect(*m.Spec.Template.Spec.Bootstrap.DataSecretName).To(Equal("data"))

0 commit comments

Comments
 (0)