Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 7aea998

Browse files
authored
Merge pull request #240 from hpandeycodeit/master
🏃Added Test :Return early if the owning machine does not have an associated cluster
2 parents e5441e0 + 2b93a31 commit 7aea998

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

controllers/kubeadmconfig_controller_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,34 @@ func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasBootstrapData(
192192
}
193193
}
194194

195+
// Return early If the owning machine does not have an associated cluster
196+
func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasNoCluster(t *testing.T) {
197+
machine := newMachine(nil, "machine") // Machine without a cluster
198+
config := newKubeadmConfig(machine, "cfg")
199+
200+
objects := []runtime.Object{
201+
machine,
202+
config,
203+
}
204+
myclient := fake.NewFakeClientWithScheme(setupScheme(), objects...)
205+
206+
k := &KubeadmConfigReconciler{
207+
Log: log.Log,
208+
Client: myclient,
209+
}
210+
211+
request := ctrl.Request{
212+
NamespacedName: types.NamespacedName{
213+
Namespace: "default",
214+
Name: "cfg",
215+
},
216+
}
217+
_, err := k.Reconcile(request)
218+
if err != nil {
219+
t.Fatalf("Not Expecting error, got an error: %+v", err)
220+
}
221+
}
222+
195223
// This does not expect an error, hoping the machine gets updated with a cluster
196224
func TestKubeadmConfigReconciler_Reconcile_ReturnNilIfMachineDoesNotHaveAssociatedCluster(t *testing.T) {
197225
machine := newMachine(nil, "machine") // intentionally omitting cluster

0 commit comments

Comments
 (0)