MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestPsetex

Function TestPsetex

IceFireDB-PubSub/test/cmd_string_test.go:352–400  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

350}
351
352func TestPsetex(t *testing.T) {
353 server.Clear()
354 c, err := proto.Dial(server.Addr())
355 ok(t, err)
356 defer c.Close()
357 s := server.Direct()
358
359 // Usual case
360 {
361 mustOK(t, c,
362 "PSETEX", "aap", "1234", "noot",
363 )
364 s.CheckGet(t, "aap", "noot")
365 equals(t, time.Millisecond*1234, s.TTL("aap"))
366 }
367
368 // Same thing
369 mustOK(t, c,
370 "PSETEX", "aap", "1234", "noot",
371 )
372
373 // Error cases
374 {
375 mustDo(t, c,
376 "PSETEX", "aap", "nottl", "noot",
377 proto.Error(msgInvalidInt),
378 )
379 mustDo(t, c,
380 "PSETEX", "aap",
381 proto.Error(errWrongNumber("psetex")),
382 )
383 mustDo(t, c,
384 "PSETEX", "aap", "12",
385 proto.Error(errWrongNumber("psetex")),
386 )
387 mustDo(t, c,
388 "PSETEX", "aap", "12", "noot", "toomuch",
389 proto.Error(errWrongNumber("psetex")),
390 )
391 mustDo(t, c,
392 "PSETEX", "aap", "0", "noot",
393 proto.Error("ERR invalid expire time in psetex"),
394 )
395 mustDo(t, c,
396 "PSETEX", "aap", "-10", "noot",
397 proto.Error("ERR invalid expire time in psetex"),
398 )
399 }
400}
401
402func TestSetnx(t *testing.T) {
403 server.Clear()

Callers

nothing calls this directly

Calls 11

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
mustOKFunction · 0.70
equalsFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected