(t *testing.T)
| 634 | } |
| 635 | |
| 636 | func TestLset(t *testing.T) { |
| 637 | server.Clear() |
| 638 | c, err := proto.Dial(server.Addr()) |
| 639 | ok(t, err) |
| 640 | defer c.Close() |
| 641 | s := server.Direct() |
| 642 | s.Push("l", "aap", "noot", "mies", "vuur", "noot", "noot") |
| 643 | // Simple LSET |
| 644 | { |
| 645 | mustOK(t, c, "LSET", "l", "1", "noot!") |
| 646 | l, err := s.List("l") |
| 647 | ok(t, err) |
| 648 | equals(t, []string{"aap", "noot!", "mies", "vuur", "noot", "noot"}, l) |
| 649 | } |
| 650 | |
| 651 | { |
| 652 | mustOK(t, c, |
| 653 | "LSET", "l", "-1", "noot?", |
| 654 | ) |
| 655 | l, err := s.List("l") |
| 656 | ok(t, err) |
| 657 | equals(t, []string{"aap", "noot!", "mies", "vuur", "noot", "noot?"}, l) |
| 658 | } |
| 659 | |
| 660 | // Out of range |
| 661 | mustDo(t, c, |
| 662 | "LSET", "l", "10000", "aap", |
| 663 | proto.Error("ERR index out of range"), |
| 664 | ) |
| 665 | mustDo(t, c, |
| 666 | "LSET", "l", "-10000", "aap", |
| 667 | proto.Error("ERR index out of range"), |
| 668 | ) |
| 669 | |
| 670 | // Non existing key |
| 671 | mustDo(t, c, |
| 672 | "LSET", "nonexisting", "0", "aap", |
| 673 | proto.Error("ERR no such key"), |
| 674 | ) |
| 675 | |
| 676 | t.Run("errors", func(t *testing.T) { |
| 677 | mustDo(t, c, |
| 678 | "LSET", |
| 679 | proto.Error(errWrongNumber("lset")), |
| 680 | ) |
| 681 | mustDo(t, c, |
| 682 | "LSET", "l", |
| 683 | proto.Error(errWrongNumber("lset")), |
| 684 | ) |
| 685 | mustDo(t, c, |
| 686 | "LSET", "l", "1", |
| 687 | proto.Error(errWrongNumber("lset")), |
| 688 | ) |
| 689 | mustDo(t, c, |
| 690 | "LSET", "l", "noint", "aap", |
| 691 | proto.Error("ERR value is not an integer or out of range"), |
| 692 | ) |
| 693 | mustDo(t, c, |
nothing calls this directly
no test coverage detected