controllers: test HelmRepository missing secretRef

This commit is contained in:
Hidde Beydals 2020-04-17 12:17:04 +02:00
parent 3c70c8d333
commit 8f09c453ab
2 changed files with 33 additions and 3 deletions

View File

@ -212,7 +212,7 @@ func (r *HelmRepositoryReconciler) shouldResetStatus(repository sourcev1.HelmRep
} }
// set initial status // set initial status
if len(repository.Status.Conditions) == 0 || resetStatus { if len(repository.Status.Conditions) == 0 {
resetStatus = true resetStatus = true
} }

View File

@ -212,8 +212,23 @@ var _ = Describe("HelmRepositoryReconciler", func() {
Eventually(func() bool { Eventually(func() bool {
got := &sourcev1.HelmRepository{} got := &sourcev1.HelmRepository{}
_ = k8sClient.Get(context.Background(), key, got) _ = k8sClient.Get(context.Background(), key, got)
return got.Status.Artifact != nil return got.Status.Artifact != nil &&
storage.ArtifactExist(*got.Status.Artifact)
}, timeout, interval).Should(BeTrue()) }, timeout, interval).Should(BeTrue())
By("Expecting missing secret error")
Expect(k8sClient.Delete(context.Background(), secret)).Should(Succeed())
got := &sourcev1.HelmRepository{}
Eventually(func() bool {
_ = k8sClient.Get(context.Background(), key, got)
for _, c := range got.Status.Conditions {
if c.Reason == sourcev1.AuthenticationFailedReason {
return true
}
}
return false
}, timeout, interval).Should(BeTrue())
Expect(got.Status.Artifact).ShouldNot(BeNil())
}) })
}) })
@ -294,7 +309,22 @@ var _ = Describe("HelmRepositoryReconciler", func() {
Eventually(func() bool { Eventually(func() bool {
got := &sourcev1.HelmRepository{} got := &sourcev1.HelmRepository{}
_ = k8sClient.Get(context.Background(), key, got) _ = k8sClient.Get(context.Background(), key, got)
return got.Status.Artifact != nil return got.Status.Artifact != nil &&
storage.ArtifactExist(*got.Status.Artifact)
}, timeout, interval).Should(BeTrue()) }, timeout, interval).Should(BeTrue())
By("Expecting missing secret error")
Expect(k8sClient.Delete(context.Background(), secret)).Should(Succeed())
got := &sourcev1.HelmRepository{}
Eventually(func() bool {
_ = k8sClient.Get(context.Background(), key, got)
for _, c := range got.Status.Conditions {
if c.Reason == sourcev1.AuthenticationFailedReason {
return true
}
}
return false
}, timeout, interval).Should(BeTrue())
Expect(got.Status.Artifact).ShouldNot(BeNil())
}) })
}) })