Skip to content

Commit

Permalink
Add test expectations for singleton controllers (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Jun 3, 2024
1 parent 9b0b033 commit 130ad49
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/expectations/expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/awslabs/operatorpkg/object"
"github.com/awslabs/operatorpkg/singleton"
"github.com/awslabs/operatorpkg/status"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -42,6 +43,20 @@ func ExpectObjectReconcileFailed[T client.Object](ctx context.Context, c client.
return Expect(err)
}

func ExpectSingletonReconciled(ctx context.Context, reconciler singleton.Reconciler) reconcile.Result {
GinkgoHelper()
result, err := singleton.AsReconciler(reconciler).Reconcile(ctx, reconcile.Request{})
Expect(err).ToNot(HaveOccurred())
return result
}

func ExpectSingletonReconcileFailed(ctx context.Context, reconciler singleton.Reconciler) error {
GinkgoHelper()
_, err := singleton.AsReconciler(reconciler).Reconcile(ctx, reconcile.Request{})
Expect(err).To(HaveOccurred())
return err
}

// Deprecated: Use the more modern ExpectObjectReconciled and reconcile.AsReconciler instead
func ExpectReconciled(ctx context.Context, reconciler reconcile.Reconciler, object client.Object) reconcile.Result {
GinkgoHelper()
Expand Down

0 comments on commit 130ad49

Please sign in to comment.