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

Function TestSetnx

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

Source from the content-addressed store, hash-verified

400}
401
402func TestSetnx(t *testing.T) {
403 server.Clear()
404 c, err := proto.Dial(server.Addr())
405 ok(t, err)
406 defer c.Close()
407 s := server.Direct()
408
409 // Existing key
410 {
411 s.Set("foo", "bar")
412 must0(t, c,
413 "SETNX", "foo", "not bar",
414 )
415 s.CheckGet(t, "foo", "bar")
416 }
417
418 // New key
419 {
420 must1(t, c,
421 "SETNX", "notfoo", "also not bar",
422 )
423 s.CheckGet(t, "notfoo", "also not bar")
424 }
425
426 // Existing key of a different type
427 {
428 s.HSet("foo", "bar", "baz")
429 must0(t, c,
430 "SETNX", "foo", "not bar",
431 )
432 equals(t, "hash", s.Type("foo"))
433 _, err = s.Get("foo")
434 equals(t, ErrWrongType, err)
435 equals(t, "baz", s.HGet("foo", "bar"))
436 }
437}
438
439func TestIncr(t *testing.T) {
440 server.Clear()

Callers

nothing calls this directly

Calls 11

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
must0Function · 0.70
must1Function · 0.70
equalsFunction · 0.70
CloseMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected