diff --git a/controllers/testdata/appconfig-setters-expected/deploy.yaml b/controllers/testdata/appconfig-setters-expected/deploy.yaml index 8edf19fa..e8394aa4 100644 --- a/controllers/testdata/appconfig-setters-expected/deploy.yaml +++ b/controllers/testdata/appconfig-setters-expected/deploy.yaml @@ -7,4 +7,4 @@ spec: spec: containers: - name: hello - image: helloworld:v1.3.1 # SETTER_SITE + image: helloworld:1.0.1 # SETTER_SITE diff --git a/controllers/update_test.go b/controllers/update_test.go index 086feaef..656a5326 100644 --- a/controllers/update_test.go +++ b/controllers/update_test.go @@ -353,15 +353,20 @@ func TestImageUpdateAutomation_e2e(t *testing.T) { Name: imagePolicyName, Namespace: namespace, } - // NB not testing the image reflector controller; this - // will make a "fully formed" ImagePolicy object. - err = createImagePolicyWithLatestImage(imagePolicyName, namespace, "not-expected-to-exist", "1.x", latestImage) - g.Expect(err).ToNot(HaveOccurred(), "failed to create ImagePolicy resource") - // Create ImageUpdateAutomation resource for each of the test cases - // and cleanup at the end. + // Create ImagePolicy and ImageUpdateAutomation resource for each of the + // test cases and cleanup at the end. t.Run("PushSpec", func(t *testing.T) { + // NB not testing the image reflector controller; this + // will make a "fully formed" ImagePolicy object. + err = createImagePolicyWithLatestImage(imagePolicyName, namespace, "not-expected-to-exist", "1.x", latestImage) + g.Expect(err).ToNot(HaveOccurred(), "failed to create ImagePolicy resource") + + defer func() { + g.Expect(deleteImagePolicy(imagePolicyName, namespace)).ToNot(HaveOccurred()) + }() + imageUpdateAutomationName := "update-" + randStringRunes(5) pushBranch := "pr-" + randStringRunes(5) @@ -435,6 +440,13 @@ func TestImageUpdateAutomation_e2e(t *testing.T) { }) t.Run("with update strategy setters", func(t *testing.T) { + err = createImagePolicyWithLatestImage(imagePolicyName, namespace, "not-expected-to-exist", "1.x", latestImage) + g.Expect(err).ToNot(HaveOccurred(), "failed to create ImagePolicy resource") + + defer func() { + g.Expect(deleteImagePolicy(imagePolicyName, namespace)).ToNot(HaveOccurred()) + }() + // Insert a setter reference into the deployment file, // before creating the automation object itself. commitInRepo(g, cloneLocalRepoURL, branch, "Install setter marker", func(tmp string) { @@ -477,6 +489,13 @@ func TestImageUpdateAutomation_e2e(t *testing.T) { }) t.Run("no reconciliation when object is suspended", func(t *testing.T) { + err = createImagePolicyWithLatestImage(imagePolicyName, namespace, "not-expected-to-exist", "1.x", latestImage) + g.Expect(err).ToNot(HaveOccurred(), "failed to create ImagePolicy resource") + + defer func() { + g.Expect(deleteImagePolicy(imagePolicyName, namespace)).ToNot(HaveOccurred()) + }() + // Create the automation object. updateKey := types.NamespacedName{ Namespace: namespace, @@ -1046,6 +1065,13 @@ func deleteImageUpdateAutomation(name, namespace string) error { return testEnv.Delete(context.Background(), update) } +func deleteImagePolicy(name, namespace string) error { + imagePolicy := &imagev1_reflect.ImagePolicy{} + imagePolicy.Name = name + imagePolicy.Namespace = namespace + return testEnv.Delete(context.Background(), imagePolicy) +} + func createSigningKeyPair(name, namespace string) (*openpgp.Entity, error) { pgpEntity, err := openpgp.NewEntity("", "", "", nil) if err != nil { diff --git a/pkg/update/result_test.go b/pkg/update/result_test.go index 0292470d..1d70643f 100644 --- a/pkg/update/result_test.go +++ b/pkg/update/result_test.go @@ -19,7 +19,7 @@ func mustRef(ref string) imageRef { return imageRef{r, types.NamespacedName{}} } -func TestMustRef(t *testing.T) { +func TestImageRef(t *testing.T) { g := NewWithT(t) t.Run("gives each component of an image ref", func(t *testing.T) {