| 920 | } |
| 921 | |
| 922 | func TestAppend(t *testing.T) { |
| 923 | server.Clear() |
| 924 | c, err := proto.Dial(server.Addr()) |
| 925 | ok(t, err) |
| 926 | defer c.Close() |
| 927 | s := server.Direct() |
| 928 | |
| 929 | // Existing key |
| 930 | { |
| 931 | s.Set("foo", "bar!") |
| 932 | mustDo(t, c, |
| 933 | "APPEND", "foo", "morebar", |
| 934 | proto.Int(11), |
| 935 | ) |
| 936 | } |
| 937 | |
| 938 | // New key |
| 939 | mustDo(t, c, |
| 940 | "APPEND", "bar", "was empty", |
| 941 | proto.Int(9), |
| 942 | ) |
| 943 | |
| 944 | // Wrong type of existing key |
| 945 | { |
| 946 | s.HSet("wrong", "aap", "noot") |
| 947 | mustDo(t, c, |
| 948 | "APPEND", "wrong", "type", |
| 949 | proto.Error(msgWrongType), |
| 950 | ) |
| 951 | } |
| 952 | |
| 953 | // Wrong usage |
| 954 | { |
| 955 | mustDo(t, c, |
| 956 | "APPEND", |
| 957 | proto.Error(errWrongNumber("append")), |
| 958 | ) |
| 959 | mustDo(t, c, |
| 960 | "APPEND", "missing", |
| 961 | proto.Error(errWrongNumber("append")), |
| 962 | ) |
| 963 | mustDo(t, c, |
| 964 | "APPEND", "spurious", "arguments", "!", |
| 965 | proto.Error(errWrongNumber("append")), |
| 966 | ) |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | func TestGetrange(t *testing.T) { |
| 971 | server.Clear() |