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

Function TestIncr

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

Source from the content-addressed store, hash-verified

437}
438
439func TestIncr(t *testing.T) {
440 server.Clear()
441 c, err := proto.Dial(server.Addr())
442 ok(t, err)
443 defer c.Close()
444 s := server.Direct()
445
446 // Existing key
447 {
448 s.Set("foo", "12")
449 mustDo(t, c,
450 "INCR", "foo",
451 proto.Int(13),
452 )
453 s.CheckGet(t, "foo", "13")
454 }
455
456 // Existing key, not an integer
457 {
458 s.Set("foo", "noint")
459 mustDo(t, c,
460 "INCR", "foo",
461 proto.Error(msgInvalidInt),
462 )
463 }
464
465 // New key
466 {
467 must1(t, c,
468 "INCR", "bar",
469 )
470 s.CheckGet(t, "bar", "1")
471 }
472
473 // Wrong type of existing key
474 {
475 s.HSet("wrong", "aap", "noot")
476 mustDo(t, c,
477 "INCR", "wrong",
478 proto.Error(msgWrongType),
479 )
480 }
481
482 // Direct usage
483 {
484 i, err := s.Incr("count", 1)
485 ok(t, err)
486 equals(t, 1, i)
487 i, err = s.Incr("count", 1)
488 ok(t, err)
489 equals(t, 2, i)
490 _, err = s.Incr("wrong", 1)
491 assert(t, err != nil, "do s.Incr error")
492 }
493
494 // Wrong usage
495 {
496 mustDo(t, c,

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
must1Function · 0.70
equalsFunction · 0.70
assertFunction · 0.70

Tested by

no test coverage detected