Skip to content

Commit

Permalink
fix: Get now correctly hydrates the object (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellistarn committed May 16, 2024
1 parent 58985b5 commit 677e8d8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions test/expectations/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test
import (
"context"
"fmt"
"reflect"
"time"

"github.com/awslabs/operatorpkg/object"
Expand Down Expand Up @@ -44,11 +43,9 @@ func ExpectReconciled(ctx context.Context, reconciler reconcile.Reconciler, obje
return result
}

func ExpectGet[T client.Object](ctx context.Context, c client.Client, obj T) T {
func ExpectGet[T client.Object](ctx context.Context, c client.Client, obj T) {
GinkgoHelper()
resp := reflect.New(reflect.TypeOf(*new(T)).Elem()).Interface().(T)
Expect(c.Get(ctx, client.ObjectKeyFromObject(obj), resp)).To(Succeed())
return resp
Expect(c.Get(ctx, client.ObjectKeyFromObject(obj), obj)).To(Succeed())
}

func ExpectNotFound(ctx context.Context, c client.Client, objects ...client.Object) {
Expand Down Expand Up @@ -80,7 +77,7 @@ func ExpectApplied(ctx context.Context, c client.Client, objects ...client.Objec
}

// Re-get the object to grab the updated spec and status
Expect(c.Get(ctx, client.ObjectKeyFromObject(o), o)).To(Succeed())
ExpectGet(ctx, c, o)
}
}

Expand Down Expand Up @@ -115,7 +112,7 @@ func ExpectStatusUpdated(ctx context.Context, c client.Client, objects ...client
// optimistic locking issues if other threads are updating objects
// e.g. pod statuses being updated during integration tests.
Expect(c.Status().Update(ctx, o.DeepCopyObject().(client.Object))).To(Succeed())
Expect(c.Get(ctx, client.ObjectKeyFromObject(o), o)).To(Succeed())
ExpectGet(ctx, c, o)
}
}

Expand Down

0 comments on commit 677e8d8

Please sign in to comment.