(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestSimpleQueue(t *testing.T) { |
| 31 | fakeClock := clock.NewFakeClock(time.Now()) |
| 32 | q := newDelayingQueue(fakeClock, "") |
| 33 | |
| 34 | first := "foo" |
| 35 | |
| 36 | q.AddAfter(first, 50*time.Millisecond) |
| 37 | if err := waitForWaitingQueueToFill(q); err != nil { |
| 38 | t.Fatalf("unexpected err: %v", err) |
| 39 | } |
| 40 | |
| 41 | if q.Len() != 0 { |
| 42 | t.Errorf("should not have added") |
| 43 | } |
| 44 | |
| 45 | fakeClock.Step(60 * time.Millisecond) |
| 46 | |
| 47 | if err := waitForAdded(q, 1); err != nil { |
| 48 | t.Errorf("should have added") |
| 49 | } |
| 50 | item, _ := q.Get() |
| 51 | q.Done(item) |
| 52 | |
| 53 | // step past the next heartbeat |
| 54 | fakeClock.Step(10 * time.Second) |
| 55 | |
| 56 | err := wait.Poll(1*time.Millisecond, 30*time.Millisecond, func() (done bool, err error) { |
| 57 | if q.Len() > 0 { |
| 58 | return false, fmt.Errorf("added to queue") |
| 59 | } |
| 60 | |
| 61 | return false, nil |
| 62 | }) |
| 63 | if err != wait.ErrWaitTimeout { |
| 64 | t.Errorf("expected timeout, got: %v", err) |
| 65 | } |
| 66 | |
| 67 | if q.Len() != 0 { |
| 68 | t.Errorf("should not have added") |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestDeduping(t *testing.T) { |
| 73 | fakeClock := clock.NewFakeClock(time.Now()) |
nothing calls this directly
no test coverage detected