diff --git a/pkg/update/testdata/setters/expected/marked.yaml b/pkg/update/testdata/setters/expected/marked.yaml index 4efafc52..cc1e72e0 100644 --- a/pkg/update/testdata/setters/expected/marked.yaml +++ b/pkg/update/testdata/setters/expected/marked.yaml @@ -12,3 +12,5 @@ spec: containers: - name: c image: updated:v1.0.1 # {"$imagepolicy": "automation-ns:policy"} + - name: d + image: image:v1.0.0 # {"$imagepolicy": "automation-ns:unchanged"} diff --git a/pkg/update/testdata/setters/original/marked.yaml b/pkg/update/testdata/setters/original/marked.yaml index 4032f9c9..aa25c15a 100644 --- a/pkg/update/testdata/setters/original/marked.yaml +++ b/pkg/update/testdata/setters/original/marked.yaml @@ -12,3 +12,5 @@ spec: containers: - name: c image: image:v1.0.0 # {"$imagepolicy": "automation-ns:policy"} + - name: d + image: image:v1.0.0 # {"$imagepolicy": "automation-ns:unchanged"} diff --git a/pkg/update/update_test.go b/pkg/update/update_test.go index 4e42f7d7..297fe457 100644 --- a/pkg/update/update_test.go +++ b/pkg/update/update_test.go @@ -38,12 +38,9 @@ func TestUpdate(t *testing.T) { } var _ = Describe("Update image via kyaml setters2", func() { - It("updates the image marked with the image policy (setter) ref", func() { - tmp, err := ioutil.TempDir("", "gotest") - Expect(err).ToNot(HaveOccurred()) - defer os.RemoveAll(tmp) - policies := []imagev1alpha1_reflect.ImagePolicy{ + var ( + policies = []imagev1alpha1_reflect.ImagePolicy{ imagev1alpha1_reflect.ImagePolicy{ ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected} Namespace: "automation-ns", @@ -53,14 +50,19 @@ var _ = Describe("Update image via kyaml setters2", func() { LatestImage: "updated:v1.0.1", }, }, + imagev1alpha1_reflect.ImagePolicy{ + ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected} + Namespace: "automation-ns", + Name: "unchanged", + }, + Status: imagev1alpha1_reflect.ImagePolicyStatus{ + LatestImage: "image:v1.0.0", + }, + }, } + ) - _, err = UpdateWithSetters("testdata/setters/original", tmp, policies) - Expect(err).ToNot(HaveOccurred()) - test.ExpectMatchingDirectories(tmp, "testdata/setters/expected") - }) - - It("gives the result of the updates", func() { + It("updates the image marked with the image policy (setter) ref", func() { tmp, err := ioutil.TempDir("", "gotest") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(tmp) @@ -75,8 +77,27 @@ var _ = Describe("Update image via kyaml setters2", func() { LatestImage: "updated:v1.0.1", }, }, + imagev1alpha1_reflect.ImagePolicy{ + ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected} + Namespace: "automation-ns", + Name: "unchanged", + }, + Status: imagev1alpha1_reflect.ImagePolicyStatus{ + LatestImage: "image:v1.0.0", + }, + }, } + _, err = UpdateWithSetters("testdata/setters/original", tmp, policies) + Expect(err).ToNot(HaveOccurred()) + test.ExpectMatchingDirectories(tmp, "testdata/setters/expected") + }) + + It("gives the result of the updates", func() { + tmp, err := ioutil.TempDir("", "gotest") + Expect(err).ToNot(HaveOccurred()) + defer os.RemoveAll(tmp) + result, err := UpdateWithSetters("testdata/setters/original", tmp, policies) Expect(err).ToNot(HaveOccurred())