Skip to content

Commit b0b2cf5

Browse files
authored
Use longer sleeps since CircleCI runs on toasters (#94)
* Use longer sleeps since CircleCI runs on toasters * redundant *1
1 parent 7f55c81 commit b0b2cf5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

retry_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ func TestAttempts(t *testing.T) {
1717
count := 0
1818
start := time.Now()
1919

20-
Attempts(5, time.Millisecond, func() error {
20+
const sleep = time.Millisecond * 10
21+
Attempts(5, sleep, func() error {
2122
count++
2223
return errors.Errorf("asdfasdf")
2324
})
2425

2526
assert.Equal(t, 5, count)
26-
assert.WithinDuration(t, start.Add(time.Millisecond*5), time.Now(), time.Millisecond*1)
27+
assert.WithinDuration(t, start.Add(sleep*5), time.Now(), sleep)
2728
})
2829

2930
t.Run("returns as soon as error is nil", func(t *testing.T) {
@@ -40,22 +41,24 @@ func TestTimeout(t *testing.T) {
4041
count := 0
4142
start := time.Now()
4243

44+
const sleep = time.Millisecond * 10
45+
4346
// The timing here is a little sketchy.
44-
Timeout((time.Millisecond * 5), time.Millisecond, func() error {
47+
Timeout((sleep * 5), sleep, func() error {
4548
count++
4649
return errors.Errorf("asdfasdf")
4750
})
4851

4952
assert.Equal(t, 5, count)
50-
assert.WithinDuration(t, start.Add(time.Millisecond*5), time.Now(), time.Millisecond*1)
53+
assert.WithinDuration(t, start.Add(sleep*5), time.Now(), sleep)
5154
})
5255

5356
t.Run("returns as soon as error is nil", func(t *testing.T) {
5457
start := time.Now()
5558
Timeout((time.Hour), time.Minute, func() error {
5659
return nil
5760
})
58-
assert.WithinDuration(t, time.Now(), start, time.Millisecond)
61+
assert.WithinDuration(t, time.Now(), start, time.Millisecond*10)
5962
})
6063
}
6164

0 commit comments

Comments
 (0)