(t *testing.T)
| 300 | } |
| 301 | |
| 302 | func TestSetex(t *testing.T) { |
| 303 | server.Clear() |
| 304 | c, err := proto.Dial(server.Addr()) |
| 305 | ok(t, err) |
| 306 | defer c.Close() |
| 307 | s := server.Direct() |
| 308 | |
| 309 | // Usual case |
| 310 | { |
| 311 | mustOK(t, c, |
| 312 | "SETEX", "aap", "1234", "noot", |
| 313 | ) |
| 314 | s.CheckGet(t, "aap", "noot") |
| 315 | equals(t, time.Second*1234, s.TTL("aap")) |
| 316 | } |
| 317 | |
| 318 | // Same thing |
| 319 | mustOK(t, c, |
| 320 | "SETEX", "aap", "1234", "noot", |
| 321 | ) |
| 322 | |
| 323 | // Error cases |
| 324 | { |
| 325 | mustDo(t, c, |
| 326 | "SETEX", "aap", "nottl", "noot", |
| 327 | proto.Error(msgInvalidInt), |
| 328 | ) |
| 329 | mustDo(t, c, |
| 330 | "SETEX", "aap", |
| 331 | proto.Error(errWrongNumber("setex")), |
| 332 | ) |
| 333 | mustDo(t, c, |
| 334 | "SETEX", "aap", "12", |
| 335 | proto.Error(errWrongNumber("setex")), |
| 336 | ) |
| 337 | mustDo(t, c, |
| 338 | "SETEX", "aap", "12", "noot", "toomuch", |
| 339 | proto.Error(errWrongNumber("setex")), |
| 340 | ) |
| 341 | mustDo(t, c, |
| 342 | "SETEX", "aap", "0", "noot", |
| 343 | proto.Error("ERR invalid expire time in setex"), |
| 344 | ) |
| 345 | mustDo(t, c, |
| 346 | "SETEX", "aap", "-10", "noot", |
| 347 | proto.Error("ERR invalid expire time in setex"), |
| 348 | ) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | func TestPsetex(t *testing.T) { |
| 353 | server.Clear() |
nothing calls this directly
no test coverage detected