Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 21, 2022
1 parent e2ae257 commit 9f2c1f1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions pkg/wrapper/exponentialBackoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"github.com/alaingilbert/clockwork"
"github.com/magiconair/properties/assert"
"sync"
"sync/atomic"
"testing"
"time"
Expand All @@ -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)
Expand All @@ -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))
}

0 comments on commit 9f2c1f1

Please sign in to comment.