(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func 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 | |
| 145 | func TestListStructure_RPop(t *testing.T) { |
| 146 | list, _ := initList() |
nothing calls this directly
no test coverage detected