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

Function TestListStructure_LSet

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

Source from the content-addressed store, hash-verified

222}
223
224func TestListStructure_LSet(t *testing.T) {
225 list, _ := initList()
226 defer list.db.Clean()
227
228 // Test LSet function when the key exists
229 listErr = list.LPush(string(randkv.GetTestKey(1)), randkv.RandomValue(100), 0)
230 assert.Nil(t, listErr)
231 listErr = list.LSet(string(randkv.GetTestKey(1)), 0, randkv.RandomValue(200), 0)
232 assert.Nil(t, listErr)
233
234 // Test LSet function when the key does not exist
235 listErr = list.LSet(string(randkv.GetTestKey(2)), 0, randkv.RandomValue(100), 0)
236 assert.Equal(t, listErr, _const.ErrKeyNotFound)
237
238 // Test LSet function when the list is empty
239 listErr = list.LPush(string(randkv.GetTestKey(3)), randkv.RandomValue(100), 0)
240 assert.Nil(t, listErr)
241 _, listErr = list.LPop(string(randkv.GetTestKey(3)))
242 assert.Nil(t, listErr)
243 listErr = list.LSet(string(randkv.GetTestKey(3)), 0, randkv.RandomValue(100), 0)
244 assert.Equal(t, listErr, ErrIndexOutOfRange)
245}
246
247func TestListStructure_LTrim(t *testing.T) {
248 list, _ := initList()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected