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

Function TestSetex

IceFireDB-Redis-Proxy/test/cmd_string_test.go:302–350  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

300}
301
302func 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
352func TestPsetex(t *testing.T) {
353 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