-
Notifications
You must be signed in to change notification settings - Fork 1
/
std_test.go
69 lines (56 loc) · 1.26 KB
/
std_test.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package timemock
import (
"time"
mock_timemock "github.com/BorisBorshevsky/timemock/internal"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Std", func() {
var mock *mock_timemock.MockClock
var mockCtl *gomock.Controller
BeforeEach(func() {
mockCtl = gomock.NewController(GinkgoT())
mock = mock_timemock.NewMockClock(mockCtl)
std = mock
})
AfterEach(func() {
mockCtl.Finish()
})
It("Now run clock.Now", func() {
t := time.Now()
mock.EXPECT().Now().Return(t)
Ω(Now()).Should(Equal(t))
})
It("Since run clock.Since", func() {
t := time.Now()
dur := time.Duration(10)
mock.EXPECT().Since(t).Return(dur)
Ω(Since(t)).Should(Equal(dur))
})
It("Until run clock.Until", func() {
t := time.Now()
dur := time.Duration(10)
mock.EXPECT().Until(t).Return(dur)
Ω(Until(t)).Should(Equal(dur))
})
It("Freeze run clock.Freeze", func() {
t := time.Now()
mock.EXPECT().Freeze(t)
Freeze(t)
})
It("Travel run clock.Travel", func() {
t := time.Now()
mock.EXPECT().Travel(t)
Travel(t)
})
It("Scale run clock.Scale", func() {
scale := float64(10)
mock.EXPECT().Scale(scale)
Scale(scale)
})
It("Now run clock.Return", func() {
mock.EXPECT().Return()
Return()
})
})