Skip to content

Commit

Permalink
Pass functions to Eventually
Browse files Browse the repository at this point in the history
Eventually takes a function, not the result of a function call.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
  • Loading branch information
skitt authored and tpantelis committed Jun 16, 2023
1 parent 657d28b commit a248118
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/cableengine/healthchecker/healthchecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ var _ = Describe("Controller", func() {

latencyInfo1 := newLatencyInfo()
pingerMap[healthCheckIP1].SetLatencyInfo(latencyInfo1)
Eventually(healthChecker.GetLatencyInfo(&endpoint1.Spec)).Should(Equal(latencyInfo1))
Eventually(func() *healthchecker.LatencyInfo { return healthChecker.GetLatencyInfo(&endpoint1.Spec) }).
Should(Equal(latencyInfo1))

latencyInfo2 := &healthchecker.LatencyInfo{
ConnectionStatus: healthchecker.ConnectionError,
Expand All @@ -163,7 +164,8 @@ var _ = Describe("Controller", func() {
}

pingerMap[healthCheckIP2].SetLatencyInfo(latencyInfo2)
Eventually(healthChecker.GetLatencyInfo(&endpoint2.Spec)).Should(Equal(latencyInfo2))
Eventually(func() *healthchecker.LatencyInfo { return healthChecker.GetLatencyInfo(&endpoint2.Spec) }).
Should(Equal(latencyInfo2))
})
})

Expand All @@ -181,7 +183,8 @@ var _ = Describe("Controller", func() {

Expect(endpoints.Delete(context.TODO(), endpoint.Name, metav1.DeleteOptions{})).To(Succeed())
pingerMap[healthCheckIP1].AwaitStop()
Eventually(healthChecker.GetLatencyInfo(&endpoint.Spec)).Should(BeNil())
Eventually(func() *healthchecker.LatencyInfo { return healthChecker.GetLatencyInfo(&endpoint.Spec) }).
Should(BeNil())
})
})

Expand All @@ -207,7 +210,8 @@ var _ = Describe("Controller", func() {

latencyInfo := newLatencyInfo()
pingerMap[healthCheckIP3].SetLatencyInfo(latencyInfo)
Eventually(healthChecker.GetLatencyInfo(&endpoint.Spec)).Should(Equal(latencyInfo))
Eventually(func() *healthchecker.LatencyInfo { return healthChecker.GetLatencyInfo(&endpoint.Spec) }).
Should(Equal(latencyInfo))
})
})

Expand Down

0 comments on commit a248118

Please sign in to comment.