| 151 | } |
| 152 | |
| 153 | func 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 | |
| 173 | type tempSwitch struct{ val *int64 } |
| 174 | |