diff --git a/pkg/reconciler/internal/updater/updater_test.go b/pkg/reconciler/internal/updater/updater_test.go index d011fa5f..b952d9a1 100644 --- a/pkg/reconciler/internal/updater/updater_test.go +++ b/pkg/reconciler/internal/updater/updater_test.go @@ -34,23 +34,6 @@ import ( const testFinalizer = "testFinalizer" -func EnsureAnnotation(key, value string) UpdateFunc { - return func(obj *unstructured.Unstructured) bool { - var hasUpdate bool - if obj.GetAnnotations() == nil { - obj.SetAnnotations(map[string]string{}) - hasUpdate = true - } - var annotations = obj.GetAnnotations() - if annotations[key] != value { - annotations[key] = value - obj.SetAnnotations(annotations) - hasUpdate = true - } - return hasUpdate - } -} - var _ = Describe("Updater", func() { var ( client client.Client @@ -76,7 +59,10 @@ var _ = Describe("Updater", func() { When("the object does not exist", func() { It("should fail", func() { Expect(client.Delete(context.TODO(), obj)).To(Succeed()) - u.Update(EnsureAnnotation("foo", "bar")) + u.Update(func(u *unstructured.Unstructured) bool { + u.SetAnnotations(map[string]string{"foo": "bar"}) + return true + }) err := u.Apply(context.TODO(), obj) Expect(err).NotTo(BeNil()) Expect(apierrors.IsNotFound(err)).To(BeTrue()) @@ -85,7 +71,10 @@ var _ = Describe("Updater", func() { When("an update is a change", func() { It("should apply an update function", func() { - u.Update(EnsureAnnotation("foo", "bar")) + u.Update(func(u *unstructured.Unstructured) bool { + u.SetAnnotations(map[string]string{"foo": "bar"}) + return true + }) resourceVersion := obj.GetResourceVersion() Expect(u.Apply(context.TODO(), obj)).To(Succeed())