*func TestRpoplpush(t *testing.T) { server.Clear() c, err := proto.Dial(server.Addr()) ok(t, err) defer c.Close() s := server.Direct() s.Push("l", "aap", "noot", "mies") s.Push("l2", "vuur", "noot", "end") { mustDo(t, c, "RPOPLPUSH", "l", "l2", proto.String("mies"), ) s.CheckList
(t *testing.T)
| 891 | }*/ |
| 892 | |
| 893 | func TestRpushx(t *testing.T) { |
| 894 | server.Clear() |
| 895 | c, err := proto.Dial(server.Addr()) |
| 896 | ok(t, err) |
| 897 | defer c.Close() |
| 898 | s := server.Direct() |
| 899 | // Simple cases |
| 900 | { |
| 901 | // No key key |
| 902 | must0(t, c, |
| 903 | "RPUSHX", "l", "value", |
| 904 | ) |
| 905 | assert(t, !s.Exists("l"), "l doesn't exist") |
| 906 | |
| 907 | s.Push("l", "aap", "noot") |
| 908 | mustDo(t, c, |
| 909 | "RPUSHX", "l", "mies", |
| 910 | proto.Int(3), |
| 911 | ) |
| 912 | |
| 913 | s.CheckList(t, "l", "aap", "noot", "mies") |
| 914 | } |
| 915 | |
| 916 | // Push more. |
| 917 | { |
| 918 | must1(t, c, |
| 919 | "LPUSH", "l2", "aap1", |
| 920 | ) |
| 921 | mustDo(t, c, |
| 922 | "RPUSHX", "l2", "aap2", "noot2", "mies2", |
| 923 | proto.Int(4), |
| 924 | ) |
| 925 | |
| 926 | mustDo(t, c, |
| 927 | "LRANGE", "l2", "0", "0", |
| 928 | proto.Strings("aap1"), |
| 929 | ) |
| 930 | |
| 931 | mustDo(t, c, |
| 932 | "LRANGE", "l2", "-1", "-1", |
| 933 | proto.Strings("mies2"), |
| 934 | ) |
| 935 | } |
| 936 | |
| 937 | t.Run("errors", func(t *testing.T) { |
| 938 | s.Push("src", "aap", "noot", "mies") |
| 939 | mustDo(t, c, |
| 940 | "RPUSHX", |
| 941 | proto.Error(errWrongNumber("rpushx")), |
| 942 | ) |
| 943 | mustDo(t, c, |
| 944 | "RPUSHX", "l", |
| 945 | proto.Error(errWrongNumber("rpushx")), |
| 946 | ) |
| 947 | s.Set("str", "string!") |
| 948 | mustDo(t, c, |
| 949 | "RPUSHX", "str", "value", |
| 950 | proto.Error(msgWrongType), |
nothing calls this directly
no test coverage detected