Skip to content

Commit 02f7721

Browse files
committed
chore: improve test
Signed-off-by: Ajay Mishra <[email protected]>
1 parent 76c66cb commit 02f7721

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

health-monitors/kubernetes-object-monitor/pkg/controller/reconciler_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,26 @@ func TestReconciler_NodeDeleted(t *testing.T) {
124124
assert.Equal(t, ctrl.Result{}, result)
125125

126126
require.Eventually(t, func() bool {
127-
return len(setup.publisher.publishedEvents) > 0
127+
return len(setup.publisher.publishedEvents) == 1 && !setup.publisher.publishedEvents[0].isHealthy
128128
}, time.Second, 50*time.Millisecond)
129129

130+
setup.publisher.publishedEvents = []mockPublishedEvent{}
131+
130132
require.NoError(t, setup.k8sClient.Delete(setup.ctx, node))
131133

132134
result, err = setup.reconciler.Reconcile(setup.ctx, ctrl.Request{
133135
NamespacedName: types.NamespacedName{Name: nodeName},
134136
})
135137
assert.NoError(t, err)
136138
assert.Equal(t, ctrl.Result{}, result)
139+
140+
require.Eventually(t, func() bool {
141+
if len(setup.publisher.publishedEvents) != 1 {
142+
return false
143+
}
144+
event := setup.publisher.publishedEvents[0]
145+
return event.nodeName == nodeName && event.isHealthy
146+
}, time.Second, 50*time.Millisecond)
137147
}
138148

139149
func TestReconciler_MultipleNodes(t *testing.T) {

0 commit comments

Comments
 (0)