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

Function TestStackClose

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

OpenStackFunction · 0.85
PushStringMethod · 0.80
PopMethod · 0.80
DropMethod · 0.45
LengthMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected