(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func 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 | |
| 169 | func TestListStructure_LRange(t *testing.T) { |
| 170 | list, _ := initList() |
nothing calls this directly
no test coverage detected