| 354 | } |
| 355 | |
| 356 | func TestRpop(t *testing.T) { |
| 357 | server.Clear() |
| 358 | c, err := proto.Dial(server.Addr()) |
| 359 | ok(t, err) |
| 360 | defer c.Close() |
| 361 | s := server.Direct() |
| 362 | s.Push("l", "aap", "noot", "mies") |
| 363 | |
| 364 | // Simple pops. |
| 365 | { |
| 366 | mustDo(t, c, |
| 367 | "RPOP", "l", |
| 368 | proto.String("mies"), |
| 369 | ) |
| 370 | |
| 371 | mustDo(t, c, |
| 372 | "RPOP", "l", |
| 373 | proto.String("noot"), |
| 374 | ) |
| 375 | |
| 376 | mustDo(t, c, |
| 377 | "RPOP", "l", |
| 378 | proto.String("aap"), |
| 379 | ) |
| 380 | |
| 381 | // Last element has been popped. Key is gone. |
| 382 | must0(t, c, "EXISTS", "l") |
| 383 | |
| 384 | // Can pop non-existing keys just fine. |
| 385 | mustNil(t, c, "RPOP", "l") |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | func TestLindex(t *testing.T) { |
| 390 | server.Clear() |