Skip to content

Commit

Permalink
Apply review suggestions: make sure assertion time span is within the…
Browse files Browse the repository at this point in the history
… grace period

Signed-off-by: Jay Chen <[email protected]>
  • Loading branch information
jijiechen committed Sep 26, 2024
1 parent 7118627 commit 4156cad
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,15 @@ var _ = Describe("MeshService generator", func() {
gracePeriodStartedAt := time.Time{}
Expect(gracePeriodStartedAt.UnmarshalText([]byte(labelGracePeriodStartedAt))).To(Succeed())

gracePeriodEndsAt := gracePeriodStartedAt.Add(gracePeriodInterval)
// Before the grace period it still exists and afterwards it eventually
// disappears
Consistently(func(g Gomega) {
err := resManager.Get(context.Background(), ms, store.GetByKey("backend", model.DefaultMesh))
if time.Now().Before(gracePeriodStartedAt.Add(gracePeriodInterval)) {
if time.Now().Before(gracePeriodEndsAt) {
g.Expect(err).To(Succeed())
}
}, gracePeriodInterval.String(), "50ms").Should(Succeed())
}, gracePeriodEndsAt.Add(-50*time.Millisecond).Sub(time.Now()).String(), "50ms").Should(Succeed())

Check failure on line 288 in pkg/core/resources/apis/meshservice/generate/generator_test.go

View workflow job for this annotation

GitHub Actions / check

S1024: should use time.Until instead of t.Sub(time.Now()) (gosimple)
Eventually(func(g Gomega) {
g.Expect(resManager.Get(context.Background(), ms, store.GetByKey("backend", model.DefaultMesh))).ToNot(Succeed())
}, "2s", "100ms").Should(Succeed())
Expand Down

0 comments on commit 4156cad

Please sign in to comment.