Skip to content

Commit

Permalink
Builder: Test happy path for TypedControllerManagedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroaleman committed Jun 29, 2024
1 parent 8cee9f3 commit 536f1d1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/builder/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/scheme"
"sigs.k8s.io/controller-runtime/pkg/source"
)

var _ untypedWatchesInput = (*WatchesInput[struct{}])(nil)
Expand Down Expand Up @@ -206,6 +207,27 @@ var _ = Describe("application", func() {
Expect(instance).To(BeNil())
})

It("should build a controller with a custom request type", func() {
By("creating a controller manager")
m, err := manager.New(cfg, manager.Options{})
Expect(err).NotTo(HaveOccurred())

instance, err := TypedControllerManagedBy[empty](m).
Named("my_controller").
WatchesRawSource(
source.TypedKind(
m.GetCache(),
&appsv1.ReplicaSet{},
handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, rs *appsv1.ReplicaSet) []empty {
return []empty{{}}
}),
),
).
Build(typedNoop)
Expect(err).To(BeNil())

Check failure on line 227 in pkg/builder/controller_test.go

View workflow job for this annotation

GitHub Actions / lint

ginkgo-linter: wrong error assertion. Consider using `Expect(err).ToNot(HaveOccurred())` instead (ginkgolinter)
Expect(instance).NotTo(BeNil())
})

It("should return an error if it cannot create the controller", func() {

By("creating a controller manager")
Expand Down

0 comments on commit 536f1d1

Please sign in to comment.