|
7 | 7 | "sort" |
8 | 8 | "testing" |
9 | 9 |
|
| 10 | + imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2" |
10 | 11 | kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2" |
11 | 12 | "github.com/fluxcd/pkg/apis/meta" |
12 | 13 | sourcev1 "github.com/fluxcd/source-controller/api/v1" |
@@ -306,7 +307,7 @@ func TestReconcilingUpdatingImagePolicy(t *testing.T) { |
306 | 307 | test.AssertNoError(t, testEnv.Create(ctx, test.ToUnstructured(t, ip))) |
307 | 308 | defer deleteObject(t, testEnv, ip) |
308 | 309 |
|
309 | | - test.AssertNoError(t, testEnv.Get(ctx, client.ObjectKeyFromObject(ip), ip)) |
| 310 | + ip = waitForResource[*imagev1.ImagePolicy](t, testEnv, ip) |
310 | 311 | ip.Status.LatestImage = "testing/test:v0.30.0" |
311 | 312 | test.AssertNoError(t, testEnv.Status().Update(ctx, ip)) |
312 | 313 |
|
@@ -342,7 +343,7 @@ func TestReconcilingUpdatingImagePolicy(t *testing.T) { |
342 | 343 | test.AssertNoError(t, testEnv.Create(ctx, gs)) |
343 | 344 | defer deleteGitOpsSetAndWaitForNotFound(t, testEnv, gs) |
344 | 345 |
|
345 | | - test.AssertNoError(t, testEnv.Get(ctx, client.ObjectKeyFromObject(ip), ip)) |
| 346 | + ip = waitForResource[*imagev1.ImagePolicy](t, testEnv, ip) |
346 | 347 | ip.Status.LatestImage = "testing/test:v0.31.0" |
347 | 348 | test.AssertNoError(t, testEnv.Status().Update(ctx, ip)) |
348 | 349 |
|
@@ -815,14 +816,23 @@ func waitForConfigMap(t *testing.T, k8sClient client.Client, src client.ObjectKe |
815 | 816 | g := gomega.NewWithT(t) |
816 | 817 | g.Eventually(func() map[string]string { |
817 | 818 | var cm corev1.ConfigMap |
818 | | - if err := testEnv.Get(ctx, src, &cm); err != nil { |
| 819 | + if err := k8sClient.Get(ctx, src, &cm); err != nil { |
819 | 820 | return nil |
820 | 821 | } |
821 | 822 |
|
822 | 823 | return cm.Data |
823 | 824 | }, timeout).Should(gomega.Equal(want)) |
824 | 825 | } |
825 | 826 |
|
| 827 | +func waitForResource[T client.Object](t *testing.T, k8sClient client.Client, obj T) T { |
| 828 | + g := gomega.NewWithT(t) |
| 829 | + g.Eventually(func() error { |
| 830 | + return k8sClient.Get(ctx, client.ObjectKeyFromObject(obj), obj) |
| 831 | + }, timeout).Should(gomega.BeNil()) |
| 832 | + |
| 833 | + return obj |
| 834 | +} |
| 835 | + |
826 | 836 | func waitForGitOpsSetInventory(t *testing.T, k8sClient client.Client, gs *templatesv1.GitOpsSet, objs ...runtime.Object) { |
827 | 837 | t.Helper() |
828 | 838 | g := gomega.NewWithT(t) |
|
0 commit comments