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

Function TestDecr

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

Source from the content-addressed store, hash-verified

707}
708
709func TestDecr(t *testing.T) {
710 server.Clear()
711 c, err := proto.Dial(server.Addr())
712 ok(t, err)
713 defer c.Close()
714 s := server.Direct()
715
716 // Existing key
717 {
718 s.Set("foo", "12")
719 mustDo(t, c,
720 "DECR", "foo",
721 proto.Int(11),
722 )
723 s.CheckGet(t, "foo", "11")
724 }
725
726 // Existing key, not an integer
727 {
728 s.Set("foo", "noint")
729 mustDo(t, c,
730 "DECR", "foo",
731 proto.Error(msgInvalidInt),
732 )
733 }
734
735 // New key
736 {
737 mustDo(t, c,
738 "DECR", "bar",
739 proto.Int(-1),
740 )
741 s.CheckGet(t, "bar", "-1")
742 }
743
744 // Wrong type of existing key
745 {
746 s.HSet("wrong", "aap", "noot")
747 mustDo(t, c,
748 "DECR", "wrong",
749 proto.Error(msgWrongType),
750 )
751 }
752
753 // Wrong usage
754 {
755 mustDo(t, c,
756 "DECR",
757 proto.Error(errWrongNumber("decr")),
758 )
759 mustDo(t, c,
760 "DECR", "new", "key",
761 proto.Error(errWrongNumber("decr")),
762 )
763 }
764
765 // Direct one works
766 {

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