(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestCopyShifting(t *testing.T) { |
| 181 | fakeClock := clock.NewFakeClock(time.Now()) |
| 182 | q := newDelayingQueue(fakeClock, "") |
| 183 | |
| 184 | first := "foo" |
| 185 | second := "bar" |
| 186 | third := "baz" |
| 187 | |
| 188 | q.AddAfter(first, 1*time.Second) |
| 189 | q.AddAfter(second, 500*time.Millisecond) |
| 190 | q.AddAfter(third, 250*time.Millisecond) |
| 191 | if err := waitForWaitingQueueToFill(q); err != nil { |
| 192 | t.Fatalf("unexpected err: %v", err) |
| 193 | } |
| 194 | |
| 195 | if q.Len() != 0 { |
| 196 | t.Errorf("should not have added") |
| 197 | } |
| 198 | |
| 199 | fakeClock.Step(2 * time.Second) |
| 200 | |
| 201 | if err := waitForAdded(q, 3); err != nil { |
| 202 | t.Fatalf("unexpected err: %v", err) |
| 203 | } |
| 204 | actualFirst, _ := q.Get() |
| 205 | if !reflect.DeepEqual(actualFirst, third) { |
| 206 | t.Errorf("expected %v, got %v", third, actualFirst) |
| 207 | } |
| 208 | actualSecond, _ := q.Get() |
| 209 | if !reflect.DeepEqual(actualSecond, second) { |
| 210 | t.Errorf("expected %v, got %v", second, actualSecond) |
| 211 | } |
| 212 | actualThird, _ := q.Get() |
| 213 | if !reflect.DeepEqual(actualThird, first) { |
| 214 | t.Errorf("expected %v, got %v", first, actualThird) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | func BenchmarkDelayingQueue_AddAfter(b *testing.B) { |
| 219 | r := rand.New(rand.NewSource(time.Now().Unix())) |
nothing calls this directly
no test coverage detected