-
Notifications
You must be signed in to change notification settings - Fork 202
/
syncTimerMock.go
47 lines (38 loc) · 1.16 KB
/
syncTimerMock.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
package mock
import (
"time"
)
// SyncTimerMock mocks the implementation for a SyncTimer
type SyncTimerMock struct {
ClockOffsetCalled func() time.Duration
CurrentTimeCalled func() time.Time
}
// StartSync method does the time synchronization at every syncPeriod time elapsed. This should be started as a go routine
func (stm SyncTimerMock) StartSync() {
panic("implement me")
}
// ClockOffset method gets the current time offset
func (stm SyncTimerMock) ClockOffset() time.Duration {
if stm.ClockOffsetCalled != nil {
return stm.ClockOffsetCalled()
}
return time.Duration(0)
}
// FormattedCurrentTime method gets the formatted current time on which is added a given offset
func (stm SyncTimerMock) FormattedCurrentTime() string {
return time.Unix(0, 0).String()
}
// CurrentTime method gets the current time on which is added the current offset
func (stm SyncTimerMock) CurrentTime() time.Time {
if stm.CurrentTimeCalled != nil {
return stm.CurrentTimeCalled()
}
return time.Unix(0, 0)
}
// IsInterfaceNil returns true if there is no value under the interface
func (stm *SyncTimerMock) IsInterfaceNil() bool {
if stm == nil {
return true
}
return false
}