(t *testing.T)
| 205 | } |
| 206 | |
| 207 | func TestLpop(t *testing.T) { |
| 208 | server.Clear() |
| 209 | c, err := proto.Dial(server.Addr()) |
| 210 | ok(t, err) |
| 211 | defer c.Close() |
| 212 | t.Run("single", func(t *testing.T) { |
| 213 | mustDo(t, c, |
| 214 | "LPUSH", "l", "aap", "noot", "mies", |
| 215 | proto.Int(3), |
| 216 | ) |
| 217 | |
| 218 | mustDo(t, c, |
| 219 | "LPOP", "l", |
| 220 | proto.String("mies"), |
| 221 | ) |
| 222 | |
| 223 | mustDo(t, c, |
| 224 | "LPOP", "l", |
| 225 | proto.String("noot"), |
| 226 | ) |
| 227 | |
| 228 | mustDo(t, c, |
| 229 | "LPOP", "l", |
| 230 | proto.String("aap"), |
| 231 | ) |
| 232 | |
| 233 | // Last element has been popped. Key is gone. |
| 234 | must0(t, c, "EXISTS", "l") |
| 235 | |
| 236 | // Can pop non-existing keys just fine. |
| 237 | mustNil(t, c, "LPOP", "l") |
| 238 | }) |
| 239 | |
| 240 | t.Run("with count", func(t *testing.T) { |
| 241 | mustDo(t, c, |
| 242 | "LPUSH", "l2", "aap", "noot", "mies", |
| 243 | proto.Int(3), |
| 244 | ) |
| 245 | |
| 246 | mustDo(t, c, |
| 247 | "LPOP", "l2", "2", |
| 248 | proto.Strings("mies", "noot"), |
| 249 | ) |
| 250 | |
| 251 | mustDo(t, c, |
| 252 | "LPOP", "l2", "2", |
| 253 | proto.Strings("aap"), |
| 254 | ) |
| 255 | |
| 256 | mustDo(t, c, |
| 257 | "LPOP", "l2", "99", |
| 258 | proto.Nil, |
| 259 | ) |
| 260 | |
| 261 | mustDo(t, c, |
| 262 | "LPOP", "l2", "0", |
| 263 | proto.Nil, |
| 264 | ) |
nothing calls this directly
no test coverage detected