diff --git a/v2/workloadapi/backoff_test.go b/v2/workloadapi/backoff_test.go index 7614ea4..9e25e32 100644 --- a/v2/workloadapi/backoff_test.go +++ b/v2/workloadapi/backoff_test.go @@ -8,26 +8,37 @@ import ( ) func TestBackoff(t *testing.T) { - b := newBackoff() - b.InitialDelay = time.Second - b.MaxDelay = 30 * time.Second + new := func() *backoff { //nolint:all + b := newBackoff() + b.InitialDelay = time.Second + b.MaxDelay = 30 * time.Second + return b + } - t.Run("test max", func(t *testing.T) { + testUntilMax := func(t *testing.T, b *backoff) { for i := 1; i < 30; i++ { require.Equal(t, time.Duration(i)*time.Second, b.Duration()) } require.Equal(t, 30*time.Second, b.Duration()) require.Equal(t, 30*time.Second, b.Duration()) require.Equal(t, 30*time.Second, b.Duration()) + } + + t.Run("test max", func(t *testing.T) { + t.Parallel() + + b := new() + testUntilMax(t, b) }) t.Run("test reset", func(t *testing.T) { + t.Parallel() + + b := new() + testUntilMax(t, b) + b.Reset() - for i := 1; i < 30; i++ { - require.Equal(t, time.Duration(i)*time.Second, b.Duration()) - } - require.Equal(t, 30*time.Second, b.Duration()) - require.Equal(t, 30*time.Second, b.Duration()) - require.Equal(t, 30*time.Second, b.Duration()) + + testUntilMax(t, b) }) } diff --git a/v2/workloadapi/watcher.go b/v2/workloadapi/watcher.go index c634961..a105a60 100644 --- a/v2/workloadapi/watcher.go +++ b/v2/workloadapi/watcher.go @@ -129,7 +129,7 @@ func (w *watcher) Close() error { w.cancel() w.wg.Wait() - // Close() can be called by New() to close a partially intialized source. + // Close() can be called by New() to close a partially initialized source. // Only close the client if it has been set and the source owns it. if w.client != nil && w.ownsClient { w.closeErr = w.client.Close()