(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestClockWithDefinedStartTime(t *testing.T) { |
| 16 | t.Parallel() |
| 17 | |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | start time.Time |
| 21 | step time.Duration |
| 22 | wants []time.Time // The return values of sequential calls to Now(). |
| 23 | }{ |
| 24 | { |
| 25 | name: "increment-ms", |
| 26 | start: time.Unix(12345, 1000), |
| 27 | step: 1000, |
| 28 | wants: []time.Time{ |
| 29 | time.Unix(12345, 1000), |
| 30 | time.Unix(12345, 2000), |
| 31 | time.Unix(12345, 3000), |
| 32 | time.Unix(12345, 4000), |
| 33 | }, |
| 34 | }, |
| 35 | { |
| 36 | name: "increment-second", |
| 37 | start: time.Unix(12345, 1000), |
| 38 | step: time.Second, |
| 39 | wants: []time.Time{ |
| 40 | time.Unix(12345, 1000), |
| 41 | time.Unix(12346, 1000), |
| 42 | time.Unix(12347, 1000), |
| 43 | time.Unix(12348, 1000), |
| 44 | }, |
| 45 | }, |
| 46 | { |
| 47 | name: "no-increment", |
| 48 | start: time.Unix(12345, 1000), |
| 49 | wants: []time.Time{ |
| 50 | time.Unix(12345, 1000), |
| 51 | time.Unix(12345, 1000), |
| 52 | time.Unix(12345, 1000), |
| 53 | time.Unix(12345, 1000), |
| 54 | }, |
| 55 | }, |
| 56 | } |
| 57 | |
| 58 | for _, tt := range tests { |
| 59 | t.Run(tt.name, func(t *testing.T) { |
| 60 | t.Parallel() |
| 61 | clock := NewClock(ClockOpts{ |
| 62 | Start: tt.start, |
| 63 | Step: tt.step, |
| 64 | }) |
| 65 | |
| 66 | if start := clock.GetStart(); !start.Equal(tt.start) { |
| 67 | t.Errorf("clock has start %v, want %v", start, tt.start) |
| 68 | } |
| 69 | if step := clock.GetStep(); step != tt.step { |
| 70 | t.Errorf("clock has step %v, want %v", step, tt.step) |
| 71 | } |
| 72 |
nothing calls this directly
no test coverage detected
searching dependent graphs…