Skip to content

Commit

Permalink
fix TestWaitForSpecificOrError some condition fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar authored and pengsrc committed Mar 27, 2017
1 parent d326815 commit 00ca5da
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions utils/wait_test.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand All @@ -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)
}
}

0 comments on commit 00ca5da

Please sign in to comment.