@@ -47,7 +47,7 @@ import (
4747 "github.com/fluxcd/image-reflector-controller/internal/test"
4848)
4949
50- func TestImagePolicyReconciler_imageRepoNotReady (t * testing.T ) {
50+ func TestImagePolicyReconciler_imageRepoHasNoTags (t * testing.T ) {
5151 g := NewWithT (t )
5252
5353 namespaceName := "imagepolicy-" + randStringRunes (5 )
@@ -65,19 +65,14 @@ func TestImagePolicyReconciler_imageRepoNotReady(t *testing.T) {
6565 Name : "repo" ,
6666 },
6767 Spec : imagev1.ImageRepositorySpec {
68- Image : "ghcr.io/stefanprodan/podinfo/foo:bar:zzz:qqq/aaa " ,
68+ Image : "ghcr.io/doesnot/exist " ,
6969 },
7070 }
7171 g .Expect (k8sClient .Create (ctx , imageRepo )).NotTo (HaveOccurred ())
7272 t .Cleanup (func () {
7373 g .Expect (k8sClient .Delete (ctx , imageRepo )).NotTo (HaveOccurred ())
7474 })
7575
76- g .Eventually (func () bool {
77- err := k8sClient .Get (ctx , client .ObjectKeyFromObject (imageRepo ), imageRepo )
78- return err == nil && conditions .IsStalled (imageRepo )
79- }).Should (BeTrue ())
80-
8176 imagePolicy := & imagev1.ImagePolicy {
8277 ObjectMeta : metav1.ObjectMeta {
8378 Namespace : namespaceName ,
@@ -87,6 +82,9 @@ func TestImagePolicyReconciler_imageRepoNotReady(t *testing.T) {
8782 ImageRepositoryRef : meta.NamespacedObjectReference {
8883 Name : imageRepo .Name ,
8984 },
85+ Policy : imagev1.ImagePolicyChoice {
86+ Alphabetical : & imagev1.AlphabeticalPolicy {},
87+ },
9088 },
9189 }
9290 g .Expect (k8sClient .Create (ctx , imagePolicy )).NotTo (HaveOccurred ())
@@ -174,15 +172,17 @@ func TestImagePolicyReconciler_ignoresImageRepoNotReadyEvent(t *testing.T) {
174172 }).Should (BeTrue ())
175173
176174 // Check that the ImagePolicy is still ready and does not get updated.
177- err := k8sClient .Get (ctx , client .ObjectKeyFromObject (imagePolicy ), imagePolicy )
178- g .Expect (err ).NotTo (HaveOccurred ())
179- g .Expect (conditions .IsReady (imagePolicy )).To (BeTrue ())
175+ g .Eventually (func () bool {
176+ err := k8sClient .Get (ctx , client .ObjectKeyFromObject (imagePolicy ), imagePolicy )
177+ return err == nil && conditions .IsReady (imagePolicy )
178+ }).Should (BeTrue ())
180179
181180 // Wait a bit and check that the ImagePolicy remains ready.
182181 time .Sleep (time .Second )
183- err = k8sClient .Get (ctx , client .ObjectKeyFromObject (imagePolicy ), imagePolicy )
184- g .Expect (err ).NotTo (HaveOccurred ())
185- g .Expect (conditions .IsReady (imagePolicy )).To (BeTrue ())
182+ g .Eventually (func () bool {
183+ err := k8sClient .Get (ctx , client .ObjectKeyFromObject (imagePolicy ), imagePolicy )
184+ return err == nil && conditions .IsReady (imagePolicy )
185+ }).Should (BeTrue ())
186186}
187187
188188func TestImagePolicyReconciler_invalidImage (t * testing.T ) {
0 commit comments