MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestListStructure_LPop

Function TestListStructure_LPop

structure/list_test.go:120–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestListStructure_LPop(t *testing.T) {
121 list, _ := initList()
122 defer list.db.Clean()
123
124 // Test LPop function when the key exists
125 listErr = list.LPush(string(randkv.GetTestKey(1)), randkv.RandomValue(100), 0)
126 assert.Nil(t, listErr)
127 listErr = list.LPush(string(randkv.GetTestKey(1)), "www", 0)
128 value, err := list.LPop(string(randkv.GetTestKey(1)))
129 assert.Nil(t, err)
130 assert.NotNil(t, value)
131
132 // Test LPop function when the key does not exist
133 _, err = list.LPop(string(randkv.GetTestKey(2)))
134 assert.Equal(t, err, _const.ErrKeyNotFound)
135
136 // Test LPop function when the list is empty
137 err = list.LPush(string(randkv.GetTestKey(3)), randkv.RandomValue(100), 0)
138 assert.Nil(t, err)
139 _, err = list.LPop(string(randkv.GetTestKey(3)))
140 assert.Nil(t, err)
141 _, err = list.LPop(string(randkv.GetTestKey(3)))
142 assert.Equal(t, err, ErrListEmpty)
143}
144
145func TestListStructure_RPop(t *testing.T) {
146 list, _ := initList()

Callers

nothing calls this directly

Calls 6

GetTestKeyFunction · 0.92
RandomValueFunction · 0.92
initListFunction · 0.85
LPushMethod · 0.65
LPopMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected