blob: 12e0a54939f04ae503a5dc2b0872437df5243380 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package clock
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestRealClock(t *testing.T) {
c := New()
assert.WithinDuration(t, time.Now(), c.Now(), time.Second)
before := c.Now()
<-c.After(time.Millisecond * 100)
after := c.Now()
assert.WithinDuration(t, before, after, time.Millisecond*120)
diff := after.Sub(before)
assert.GreaterOrEqual(t, diff, time.Millisecond*100)
}
|