(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestBringToFront(t *testing.T) { |
| 126 | q := newJobQueue() |
| 127 | q.Push("f1", 0, time.Time{}) |
| 128 | q.Push("f2", 0, time.Time{}) |
| 129 | q.Push("f3", 0, time.Time{}) |
| 130 | q.Push("f4", 0, time.Time{}) |
| 131 | |
| 132 | _, queued, _ := q.Jobs(1, 100) |
| 133 | if diff, equal := messagediff.PrettyDiff([]string{"f1", "f2", "f3", "f4"}, queued); !equal { |
| 134 | t.Errorf("Order does not match. Diff:\n%s", diff) |
| 135 | } |
| 136 | |
| 137 | q.BringToFront("f1") // corner case: does nothing |
| 138 | |
| 139 | _, queued, _ = q.Jobs(1, 100) |
| 140 | if diff, equal := messagediff.PrettyDiff([]string{"f1", "f2", "f3", "f4"}, queued); !equal { |
| 141 | t.Errorf("Order does not match. Diff:\n%s", diff) |
| 142 | } |
| 143 | |
| 144 | q.BringToFront("f3") |
| 145 | |
| 146 | _, queued, _ = q.Jobs(1, 100) |
| 147 | if diff, equal := messagediff.PrettyDiff([]string{"f3", "f1", "f2", "f4"}, queued); !equal { |
| 148 | t.Errorf("Order does not match. Diff:\n%s", diff) |
| 149 | } |
| 150 | |
| 151 | q.BringToFront("f2") |
| 152 | |
| 153 | _, queued, _ = q.Jobs(1, 100) |
| 154 | if diff, equal := messagediff.PrettyDiff([]string{"f2", "f3", "f1", "f4"}, queued); !equal { |
| 155 | t.Errorf("Order does not match. Diff:\n%s", diff) |
| 156 | } |
| 157 | |
| 158 | q.BringToFront("f4") // corner case: last element |
| 159 | |
| 160 | _, queued, _ = q.Jobs(1, 100) |
| 161 | if diff, equal := messagediff.PrettyDiff([]string{"f4", "f2", "f3", "f1"}, queued); !equal { |
| 162 | t.Errorf("Order does not match. Diff:\n%s", diff) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func BenchmarkJobQueueBump(b *testing.B) { |
| 167 | files := genFiles(10000) |
nothing calls this directly
no test coverage detected