(t *testing.T)
| 140 | } |
| 141 | |
| 142 | func TestLpushx(t *testing.T) { |
| 143 | server.Clear() |
| 144 | c, err := proto.Dial(server.Addr()) |
| 145 | ok(t, err) |
| 146 | defer c.Close() |
| 147 | s := server.Direct() |
| 148 | { |
| 149 | must0(t, c, |
| 150 | "LPUSHX", "l", "aap", |
| 151 | ) |
| 152 | equals(t, false, s.Exists("l")) |
| 153 | |
| 154 | // Create the list with a normal LPUSH |
| 155 | must1(t, c, |
| 156 | "LPUSH", "l", "noot", |
| 157 | ) |
| 158 | equals(t, true, s.Exists("l")) |
| 159 | |
| 160 | mustDo(t, c, |
| 161 | "LPUSHX", "l", "mies", |
| 162 | proto.Int(2), |
| 163 | ) |
| 164 | equals(t, true, s.Exists("l")) |
| 165 | } |
| 166 | |
| 167 | // Push more. |
| 168 | { |
| 169 | must1(t, c, |
| 170 | "LPUSH", "l2", "aap1", |
| 171 | ) |
| 172 | mustDo(t, c, |
| 173 | "LPUSHX", "l2", "aap2", "noot2", "mies2", |
| 174 | proto.Int(4), |
| 175 | ) |
| 176 | |
| 177 | mustDo(t, c, |
| 178 | "LRANGE", "l2", "0", "0", |
| 179 | proto.Strings("mies2"), |
| 180 | ) |
| 181 | |
| 182 | mustDo(t, c, |
| 183 | "LRANGE", "l2", "-1", "-1", |
| 184 | proto.Strings("aap1"), |
| 185 | ) |
| 186 | } |
| 187 | |
| 188 | // Errors |
| 189 | { |
| 190 | mustDo(t, c, |
| 191 | "LPUSHX", |
| 192 | proto.Error("ERR wrong number of arguments for 'lpushx' command"), |
| 193 | ) |
| 194 | mustDo(t, c, |
| 195 | "LPUSHX", "l", |
| 196 | proto.Error("ERR wrong number of arguments for 'lpushx' command"), |
| 197 | ) |
| 198 | |
| 199 | mustOK(t, c, "SET", "str", "value") |
nothing calls this directly
no test coverage detected