MCPcopy Create free account
hub / github.com/cabify/timex / ExampleTestImplementation_NewTimer

Function ExampleTestImplementation_NewTimer

timextest/example_test.go:153–171  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

151}
152
153func ExampleTestImplementation_NewTimer() {
154 timextest.Mocked(now, func(mockedtimex *timextest.TestImplementation) {
155 wg := sync.WaitGroup{}
156 wg.Add(1)
157 go func(d time.Duration) {
158 defer wg.Done()
159 ticker := timex.NewTimer(d)
160 t := <-ticker.C()
161 fmt.Println(t)
162 }(time.Minute)
163
164 timer := <-mockedtimex.NewTimerCalls
165 timer.Mock.Trigger(now.Add(timer.Duration))
166 wg.Wait()
167
168 // Output:
169 // 2009-11-10 23:01:00 +0000 UTC
170 })
171}
172
173type tempSwitch struct{ val *int64 }
174

Callers

nothing calls this directly

Calls 4

CMethod · 0.95
MockedFunction · 0.92
NewTimerFunction · 0.92
TriggerMethod · 0.80

Tested by

no test coverage detected