Skip to content

Commit

Permalink
Truncate time in test to microsecond precision
Browse files Browse the repository at this point in the history
  • Loading branch information
shafeeqes committed Jan 29, 2023
1 parent 2622f89 commit e1a11f5
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("Extensions Heartbeat Controller tests", func() {
g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(lease), lease)).To(Succeed())
g.Expect(lease.Spec.LeaseDurationSeconds).To(PointTo(Equal(int32(1))))
g.Expect(lease.Spec.HolderIdentity).To(PointTo(Equal(testID)))
g.Expect(lease.Spec.RenewTime.Equal(&metav1.MicroTime{Time: fakeClock.Now()})).To(BeTrue())
g.Expect(lease.Spec.RenewTime.Equal(&metav1.MicroTime{Time: fakeClock.Now().Truncate(time.Microsecond)})).To(BeTrue())
}).Should(Succeed())

By("Step fake clock")
Expand All @@ -54,7 +54,7 @@ var _ = Describe("Extensions Heartbeat Controller tests", func() {
By("Wait until heartbeat lease's RenewTime is updated")
Eventually(func(g Gomega) {
g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(lease), lease)).To(Succeed())
g.Expect(lease.Spec.RenewTime.Equal(&metav1.MicroTime{Time: fakeClock.Now()})).To(BeTrue())
g.Expect(lease.Spec.RenewTime.Equal(&metav1.MicroTime{Time: fakeClock.Now().Truncate(time.Microsecond)})).To(BeTrue())
}).Should(Succeed())
})
})

0 comments on commit e1a11f5

Please sign in to comment.