From 9f2c1f1eef53d18e8aa2fe39fdd8e5faec0a3ff6 Mon Sep 17 00:00:00 2001 From: Alain Gilbert Date: Sat, 20 Aug 2022 22:18:22 -0700 Subject: [PATCH] simplify test --- pkg/wrapper/exponentialBackoff_test.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pkg/wrapper/exponentialBackoff_test.go b/pkg/wrapper/exponentialBackoff_test.go index cd63d396..b82e1387 100644 --- a/pkg/wrapper/exponentialBackoff_test.go +++ b/pkg/wrapper/exponentialBackoff_test.go @@ -4,7 +4,6 @@ import ( "context" "github.com/alaingilbert/clockwork" "github.com/magiconair/properties/assert" - "sync" "sync/atomic" "testing" "time" @@ -13,8 +12,6 @@ import ( func TestExponentialBackoff_Wait(t *testing.T) { var counter uint32 clock := clockwork.NewFakeClock() - wg := &sync.WaitGroup{} - wg.Add(1) go func() { clock.BlockUntil(1) clock.Advance(1000 * time.Millisecond) @@ -27,15 +24,11 @@ func TestExponentialBackoff_Wait(t *testing.T) { clock.BlockUntil(0) atomic.AddUint32(&counter, 1) }() - go func() { - e := NewExponentialBackoff(context.Background(), 60) - e.SetClock(clock) - e.Wait() // First time has no wait - e.Wait() // Wait 1s - e.Wait() // Wait 2s - e.Wait() // Wait 4s - wg.Done() - }() - wg.Wait() + e := NewExponentialBackoff(context.Background(), 60) + e.SetClock(clock) + e.Wait() // First time has no wait + e.Wait() // Wait 1s + e.Wait() // Wait 2s + e.Wait() // Wait 4s assert.Equal(t, uint32(1), atomic.LoadUint32(&counter)) }