(t *testing.T)
| 704 | } |
| 705 | |
| 706 | func TestLinsert(t *testing.T) { |
| 707 | server.Clear() |
| 708 | c, err := proto.Dial(server.Addr()) |
| 709 | ok(t, err) |
| 710 | defer c.Close() |
| 711 | s := server.Direct() |
| 712 | s.Push("l", "aap", "noot", "mies", "vuur", "noot", "end") |
| 713 | // Before |
| 714 | { |
| 715 | mustDo(t, c, |
| 716 | "LINSERT", "l", "BEFORE", "noot", "!", |
| 717 | proto.Int(7), |
| 718 | ) |
| 719 | l, err := s.List("l") |
| 720 | ok(t, err) |
| 721 | equals(t, []string{"aap", "!", "noot", "mies", "vuur", "noot", "end"}, l) |
| 722 | } |
| 723 | |
| 724 | // After |
| 725 | { |
| 726 | mustDo(t, c, |
| 727 | "LINSERT", "l", "AFTER", "noot", "?", |
| 728 | proto.Int(8), |
| 729 | ) |
| 730 | l, err := s.List("l") |
| 731 | ok(t, err) |
| 732 | equals(t, []string{"aap", "!", "noot", "?", "mies", "vuur", "noot", "end"}, l) |
| 733 | } |
| 734 | |
| 735 | // Edge case before |
| 736 | { |
| 737 | mustDo(t, c, |
| 738 | "LINSERT", "l", "BEFORE", "aap", "[", |
| 739 | proto.Int(9), |
| 740 | ) |
| 741 | l, err := s.List("l") |
| 742 | ok(t, err) |
| 743 | equals(t, []string{"[", "aap", "!", "noot", "?", "mies", "vuur", "noot", "end"}, l) |
| 744 | } |
| 745 | |
| 746 | // Edge case after |
| 747 | { |
| 748 | mustDo(t, c, |
| 749 | "LINSERT", "l", "AFTER", "end", "]", |
| 750 | proto.Int(10), |
| 751 | ) |
| 752 | l, err := s.List("l") |
| 753 | ok(t, err) |
| 754 | equals(t, []string{"[", "aap", "!", "noot", "?", "mies", "vuur", "noot", "end", "]"}, l) |
| 755 | } |
| 756 | |
| 757 | // Non existing pivot |
| 758 | mustDo(t, c, |
| 759 | "LINSERT", "l", "before", "nosuch", "noot", |
| 760 | proto.Int(-1), |
| 761 | ) |
| 762 | |
| 763 | // Non existing key |
nothing calls this directly
no test coverage detected