| 255 | } |
| 256 | |
| 257 | func TestMset(t *testing.T) { |
| 258 | server.Clear() |
| 259 | c, err := proto.Dial(server.Addr()) |
| 260 | ok(t, err) |
| 261 | defer c.Close() |
| 262 | s := server.Direct() |
| 263 | |
| 264 | { |
| 265 | mustOK(t, c, |
| 266 | "MSET", "zus", "jet", "teun", "vuur", "gijs", "lam", |
| 267 | ) |
| 268 | s.CheckGet(t, "zus", "jet") |
| 269 | s.CheckGet(t, "teun", "vuur") |
| 270 | s.CheckGet(t, "gijs", "lam") |
| 271 | } |
| 272 | |
| 273 | // Other types are overwritten |
| 274 | { |
| 275 | s.HSet("aap", "foo", "bar") |
| 276 | mustOK(t, c, |
| 277 | "MSET", "aap", "jet", |
| 278 | ) |
| 279 | s.CheckGet(t, "aap", "jet") |
| 280 | } |
| 281 | |
| 282 | // Odd argument list is not OK |
| 283 | mustDo(t, c, |
| 284 | "MSET", "zus", "jet", "teun", |
| 285 | proto.Error("ERR wrong number of arguments for 'MSET' command"), |
| 286 | ) |
| 287 | |
| 288 | // TTL is cleared |
| 289 | { |
| 290 | s.Set("foo", "bar") |
| 291 | s.HSet("aap", "foo", "bar") // even for weird keys. |
| 292 | s.SetTTL("aap", time.Second*999) |
| 293 | s.SetTTL("foo", time.Second*999) |
| 294 | mustOK(t, c, |
| 295 | "MSET", "aap", "noot", "foo", "baz", |
| 296 | ) |
| 297 | equals(t, time.Duration(0), s.TTL("aap")) |
| 298 | equals(t, time.Duration(0), s.TTL("foo")) |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func TestSetex(t *testing.T) { |
| 303 | server.Clear() |