From 00ca5dab1930c779d600355d472782fd5f91e346 Mon Sep 17 00:00:00 2001 From: jolestar Date: Mon, 27 Mar 2017 11:55:37 +0800 Subject: [PATCH] fix TestWaitForSpecificOrError some condition fail. --- utils/wait_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/wait_test.go b/utils/wait_test.go index 6fa9416..973d6d1 100644 --- a/utils/wait_test.go +++ b/utils/wait_test.go @@ -1,19 +1,19 @@ package utils import ( + "errors" + "github.com/stretchr/testify/assert" "testing" "time" - "github.com/stretchr/testify/assert" - "errors" ) -func TestWaitForSpecificOrError(t *testing.T){ +func TestWaitForSpecificOrError(t *testing.T) { - waitInterval := 100*time.Millisecond - timeout := 1000*time.Millisecond + waitInterval := 100 * time.Millisecond + timeout := 10*waitInterval + waitInterval/2 times := 0 err := WaitForSpecificOrError(func() (bool, error) { - times ++ + times++ println("times", times) if times == 3 { return true, nil @@ -25,7 +25,7 @@ func TestWaitForSpecificOrError(t *testing.T){ times = 0 err = WaitForSpecificOrError(func() (bool, error) { - times ++ + times++ println("times", times) if times == 3 { return false, errors.New("error") @@ -37,10 +37,10 @@ func TestWaitForSpecificOrError(t *testing.T){ times = 0 err = WaitForSpecificOrError(func() (bool, error) { - times ++ + times++ println("times", times) return false, nil }, timeout, waitInterval) assert.Error(t, err) assert.Equal(t, 10, times) -} \ No newline at end of file +}