(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestPriorityQueueClose(t *testing.T) { |
| 12 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
| 13 | pq, err := OpenPriorityQueue(file, ASC) |
| 14 | if err != nil { |
| 15 | t.Error(err) |
| 16 | } |
| 17 | defer pq.Drop() |
| 18 | |
| 19 | for p := 0; p <= 4; p++ { |
| 20 | for i := 1; i <= 10; i++ { |
| 21 | if _, err = pq.EnqueueString(uint8(p), fmt.Sprintf("value for item %d", i)); err != nil { |
| 22 | t.Error(err) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | if pq.Length() != 50 { |
| 28 | t.Errorf("Expected queue length of 1, got %d", pq.Length()) |
| 29 | } |
| 30 | |
| 31 | pq.Close() |
| 32 | |
| 33 | if _, err = pq.Dequeue(); err != ErrDBClosed { |
| 34 | t.Errorf("Expected to get database closed error, got %s", err.Error()) |
| 35 | } |
| 36 | |
| 37 | if pq.Length() != 0 { |
| 38 | t.Errorf("Expected queue length of 0, got %d", pq.Length()) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestPriorityQueueDrop(t *testing.T) { |
| 43 | file := fmt.Sprintf("test_db_%d", time.Now().UnixNano()) |
nothing calls this directly
no test coverage detected