controllers: test HelmChart missing HelmRepository

This commit is contained in:
Hidde Beydals 2020-04-17 20:39:33 +02:00
parent 7e7f1ccd89
commit 236a6950cd
2 changed files with 18 additions and 1 deletions

View File

@ -269,7 +269,7 @@ func (r *HelmChartReconciler) shouldResetStatus(chart sourcev1.HelmChart) (bool,
}
// set initial status
if len(chart.Status.Conditions) == 0 || resetStatus {
if len(chart.Status.Conditions) == 0 {
resetStatus = true
}

View File

@ -127,6 +127,23 @@ var _ = Describe("HelmChartReconciler", func() {
!storage.ArtifactExist(*got.Status.Artifact)
}, timeout, interval).Should(BeTrue())
By("Expecting missing HelmRepository error")
updated := &sourcev1.HelmChart{}
Expect(k8sClient.Get(context.Background(), key, updated)).Should(Succeed())
updated.Spec.HelmRepositoryRef.Name = "invalid"
Expect(k8sClient.Update(context.Background(), updated)).Should(Succeed())
Eventually(func() bool {
_ = k8sClient.Get(context.Background(), key, updated)
for _, c := range updated.Status.Conditions {
if c.Reason == sourcev1.ChartPullFailedReason &&
strings.Contains(c.Message, "failed to get HelmRepository") {
return true
}
}
return false
}, timeout, interval).Should(BeTrue())
Expect(updated.Status.Artifact).ToNot(BeNil())
By("Expecting to delete successfully")
got = &sourcev1.HelmChart{}
Eventually(func() error {