From 84e2d6c3d32a4fc96df067d7a31b22a3ab95ab12 Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Sat, 2 Jan 2016 14:48:30 +0100 Subject: [PATCH] Fix TestPoll test --- pkg/util/wait/wait_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/util/wait/wait_test.go b/pkg/util/wait/wait_test.go index e027a448103..54d35637f3c 100644 --- a/pkg/util/wait/wait_test.go +++ b/pkg/util/wait/wait_test.go @@ -84,7 +84,7 @@ func TestPoll(t *testing.T) { return true, nil }) fp := fakePoller{max: 1} - if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Microsecond), f); err != nil { + if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Second), f); err != nil { t.Fatalf("unexpected error %v", err) } if invocations != 1 { @@ -94,19 +94,18 @@ func TestPoll(t *testing.T) { if used != 1 { t.Errorf("Expected exactly one tick, got %d", used) } +} +func TestPollError(t *testing.T) { expectedError := errors.New("Expected error") - f = ConditionFunc(func() (bool, error) { + f := ConditionFunc(func() (bool, error) { return false, expectedError }) - fp = fakePoller{max: 1} - if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Microsecond), f); err == nil || err != expectedError { + fp := fakePoller{max: 1} + if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Second), f); err == nil || err != expectedError { t.Fatalf("Expected error %v, got none %v", expectedError, err) } - if invocations != 1 { - t.Errorf("Expected exactly one invocation, got %d", invocations) - } - used = atomic.LoadInt32(&fp.used) + used := atomic.LoadInt32(&fp.used) if used != 1 { t.Errorf("Expected exactly one tick, got %d", used) }