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

Function TestListStructure_RPop

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

Source from the content-addressed store, hash-verified

143}
144
145func TestListStructure_RPop(t *testing.T) {
146 list, _ := initList()
147 defer list.db.Clean()
148
149 // Test RPop function when the key exists
150 listErr = list.RPush(string(randkv.GetTestKey(1)), randkv.RandomValue(100), 0)
151 assert.Nil(t, listErr)
152 value, err := list.RPop(string(randkv.GetTestKey(1)))
153 assert.Nil(t, err)
154 assert.NotNil(t, value)
155
156 // Test RPop function when the key does not exist
157 _, err = list.RPop(string(randkv.GetTestKey(2)))
158 assert.Equal(t, err, _const.ErrKeyNotFound)
159
160 // Test RPop function when the list is empty
161 err = list.RPush(string(randkv.GetTestKey(3)), randkv.RandomValue(100), 0)
162 assert.Nil(t, err)
163 _, err = list.RPop(string(randkv.GetTestKey(3)))
164 assert.Nil(t, err)
165 _, err = list.RPop(string(randkv.GetTestKey(3)))
166 assert.Equal(t, err, ErrListEmpty)
167}
168
169func TestListStructure_LRange(t *testing.T) {
170 list, _ := initList()

Callers

nothing calls this directly

Calls 6

GetTestKeyFunction · 0.92
RandomValueFunction · 0.92
initListFunction · 0.85
RPushMethod · 0.65
RPopMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected