(t *testing.T)
| 537 | } |
| 538 | |
| 539 | func TestLrem(t *testing.T) { |
| 540 | server.Clear() |
| 541 | c, err := proto.Dial(server.Addr()) |
| 542 | ok(t, err) |
| 543 | defer c.Close() |
| 544 | s := server.Direct() |
| 545 | // Reverse |
| 546 | { |
| 547 | s.Push("l", "aap", "noot", "mies", "vuur", "noot", "noot") |
| 548 | must1(t, c, |
| 549 | "LREM", "l", "-1", "noot", |
| 550 | ) |
| 551 | l, err := s.List("l") |
| 552 | ok(t, err) |
| 553 | equals(t, []string{"aap", "noot", "mies", "vuur", "noot"}, l) |
| 554 | } |
| 555 | // Normal |
| 556 | { |
| 557 | s.Push("l2", "aap", "noot", "mies", "vuur", "noot", "noot") |
| 558 | mustDo(t, c, |
| 559 | "LREM", "l2", "2", "noot", |
| 560 | proto.Int(2), |
| 561 | ) |
| 562 | l, err := s.List("l2") |
| 563 | ok(t, err) |
| 564 | equals(t, []string{"aap", "mies", "vuur", "noot"}, l) |
| 565 | } |
| 566 | |
| 567 | // All |
| 568 | { |
| 569 | s.Push("l3", "aap", "noot", "mies", "vuur", "noot", "noot") |
| 570 | mustDo(t, c, |
| 571 | "LREM", "l3", "0", "noot", |
| 572 | proto.Int(3), |
| 573 | ) |
| 574 | l, err := s.List("l3") |
| 575 | ok(t, err) |
| 576 | equals(t, []string{"aap", "mies", "vuur"}, l) |
| 577 | } |
| 578 | |
| 579 | // All |
| 580 | { |
| 581 | s.Push("l4", "aap", "noot", "mies", "vuur", "noot", "noot") |
| 582 | mustDo(t, c, |
| 583 | "LREM", "l4", "200", "noot", |
| 584 | proto.Int(3), |
| 585 | ) |
| 586 | l, err := s.List("l4") |
| 587 | ok(t, err) |
| 588 | equals(t, []string{"aap", "mies", "vuur"}, l) |
| 589 | } |
| 590 | |
| 591 | // Delete key on empty list |
| 592 | { |
| 593 | s.Push("l5", "noot", "noot", "noot") |
| 594 | mustDo(t, c, |
| 595 | "LREM", "l5", "99", "noot", |
| 596 | proto.Int(3), |
nothing calls this directly
no test coverage detected