Skip to content

Commit

Permalink
PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ludydoo committed Jun 27, 2023
1 parent 077e623 commit df6d950
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions pkg/reconciler/internal/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit df6d950

Please sign in to comment.