(t *testing.T)
| 222 | } |
| 223 | |
| 224 | func 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 | |
| 247 | func TestListStructure_LTrim(t *testing.T) { |
| 248 | list, _ := initList() |
nothing calls this directly
no test coverage detected