| OLD | NEW |
| 1 package main | 1 package main |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "fmt" | 4 "fmt" |
| 5 "testing" | 5 "testing" |
| 6 "time" | 6 "time" |
| 7 | 7 |
| 8 "github.com/luci/luci-go/common/clock" |
| 9 "github.com/luci/luci-go/common/clock/testclock" |
| 8 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
| 9 "infra/libs/clock" | |
| 10 "infra/libs/clock/testclock" | |
| 11 ) | 11 ) |
| 12 | 12 |
| 13 // Should run f at least once, even if the duration is 0. | 13 // Should run f at least once, even if the duration is 0. |
| 14 func TestLoopOnce(t *testing.T) { | 14 func TestLoopOnce(t *testing.T) { |
| 15 _, c := testclock.UseTime(context.Background(), time.Unix(0, 0)) | 15 _, c := testclock.UseTime(context.Background(), time.Unix(0, 0)) |
| 16 | 16 |
| 17 nCalls := 0 | 17 nCalls := 0 |
| 18 f := func() error { | 18 f := func() error { |
| 19 log.Infof("tick") | 19 log.Infof("tick") |
| 20 nCalls++ | 20 nCalls++ |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 // Now read off the rest of the timer ticks. | 224 // Now read off the rest of the timer ticks. |
| 225 for i := 0; i < 7; i++ { | 225 for i := 0; i < 7; i++ { |
| 226 <-timerStartedC | 226 <-timerStartedC |
| 227 c.Add(1 * time.Second) | 227 c.Add(1 * time.Second) |
| 228 } | 228 } |
| 229 | 229 |
| 230 c.Add(1 * time.Second) | 230 c.Add(1 * time.Second) |
| 231 <-done | 231 <-done |
| 232 } | 232 } |
| OLD | NEW |