MCPcopy Create free account
hub / github.com/beeker1121/goque / TestQueueClose

Function TestQueueClose

queue_test.go:10–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestQueueClose(t *testing.T) {
11 file := fmt.Sprintf("test_db_%d", time.Now().UnixNano())
12 q, err := OpenQueue(file)
13 if err != nil {
14 t.Error(err)
15 }
16 defer q.Drop()
17
18 if _, err = q.EnqueueString("value"); err != nil {
19 t.Error(err)
20 }
21
22 if q.Length() != 1 {
23 t.Errorf("Expected queue length of 1, got %d", q.Length())
24 }
25
26 q.Close()
27
28 if _, err = q.Dequeue(); err != ErrDBClosed {
29 t.Errorf("Expected to get database closed error, got %s", err.Error())
30 }
31
32 if q.Length() != 0 {
33 t.Errorf("Expected queue length of 0, got %d", q.Length())
34 }
35}
36
37func TestQueueDrop(t *testing.T) {
38 file := fmt.Sprintf("test_db_%d", time.Now().UnixNano())

Callers

nothing calls this directly

Calls 6

OpenQueueFunction · 0.85
DropMethod · 0.45
EnqueueStringMethod · 0.45
LengthMethod · 0.45
CloseMethod · 0.45
DequeueMethod · 0.45

Tested by

no test coverage detected