Skip to content

Commit d82440c

Browse files
authored
🌱Add tests for PR 1413 (#1445)
1 parent 39ff9be commit d82440c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

controllers/hcloudmachine_controller_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,25 @@ var _ = Describe("HCloudMachineReconciler", func() {
581581
}, timeout).Should(BeTrue())
582582
})
583583
})
584+
Context("should show error when ssh key empty", func() {
585+
BeforeEach(func() {
586+
hetznerCluster.Spec.SSHKeys.HCloud = nil
587+
hcloudMachine.Spec.SSHKeys = nil
588+
hetznerCluster.Spec.HetznerSecret.Key.SSHKey = ""
589+
Expect(testEnv.Create(ctx, hetznerCluster)).To(Succeed())
590+
Expect(testEnv.Create(ctx, hcloudMachine)).To(Succeed())
591+
})
592+
593+
AfterEach(func() {
594+
Expect(testEnv.Cleanup(ctx, hetznerCluster, hcloudMachine)).To(Succeed())
595+
})
596+
597+
It("should show the expected reason for server not created", func() {
598+
Eventually(func() bool {
599+
return isPresentAndFalseWithReason(key, hcloudMachine, infrav1.ServerCreateSucceededCondition, infrav1.SSHKeyNotFoundReason)
600+
}, timeout).Should(BeTrue())
601+
})
602+
})
584603

585604
Context("with public network specs", func() {
586605
BeforeEach(func() {

0 commit comments

Comments
 (0)