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

Function TestDecrBy

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

Source from the content-addressed store, hash-verified

644}
645
646func TestDecrBy(t *testing.T) {
647 server.Clear()
648 c, err := proto.Dial(server.Addr())
649 ok(t, err)
650 defer c.Close()
651 s := server.Direct()
652
653 // Existing key
654 {
655 s.Set("foo", "12")
656 mustDo(t, c,
657 "DECRBY", "foo", "400",
658 proto.Int(-388),
659 )
660 s.CheckGet(t, "foo", "-388")
661 }
662
663 // Existing key, not an integer
664 {
665 s.Set("foo", "noint")
666 mustDo(t, c,
667 "DECRBY", "foo", "400",
668 proto.Error(msgInvalidInt),
669 )
670 }
671
672 // New key
673 {
674 mustDo(t, c,
675 "DECRBY", "bar", "4000",
676 proto.Int(-4000),
677 )
678 s.CheckGet(t, "bar", "-4000")
679 }
680
681 // Wrong type of existing key
682 {
683 s.HSet("wrong", "aap", "noot")
684 mustDo(t, c,
685 "DECRBY", "wrong", "400",
686 proto.Error(msgWrongType),
687 )
688 }
689
690 // Amount not an integer
691 mustDo(t, c,
692 "DECRBY", "key", "noint",
693 proto.Error(msgInvalidInt),
694 )
695
696 // Wrong usage
697 {
698 mustDo(t, c,
699 "DECRBY",
700 proto.Error(errWrongNumber("decrby")),
701 )
702 mustDo(t, c,
703 "DECRBY", "another", "new", "key",

Callers

nothing calls this directly

Calls 11

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
errWrongNumberFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected