Skip to content

Commit

Permalink
Update tracker tests
Browse files Browse the repository at this point in the history
- Add testing for multiple reconcilers tracking the same kind
  • Loading branch information
tomkennedy513 committed May 18, 2023
1 parent 9c9b410 commit 6a738b2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/tracker/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,34 @@ func testTracker(t *testing.T, when spec.G, it spec.S) {

require.Equal(t, wasCalledWith, types.NamespacedName{})
})

it("supports multiple reconcilers tracking the same kind", func() {
calledWith := []types.NamespacedName{}
track := tracker.New(func(key types.NamespacedName) {
calledWith = append(calledWith, key)
}, 5*time.Minute)

builder := &buildapi.Builder{
ObjectMeta: v1.ObjectMeta{
Name: "some-name",
},
TypeMeta: v1.TypeMeta{
Kind: "Builder",
APIVersion: "kpack.io/v1alpha2",
},
}

secondReconciler := types.NamespacedName{Name: "second reconciler", Namespace: "some namespace"}

track.TrackKind(groupKind, reconcilerName)
track.TrackKind(groupKind, secondReconciler)

track.OnChanged(builder)

require.Len(t, calledWith, 2)
require.Contains(t, calledWith, reconcilerName)
require.Contains(t, calledWith, secondReconciler)
})
})

when("tracking expires", func() {
Expand Down

0 comments on commit 6a738b2

Please # to comment.