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

Function TestGetSet

IceFireDB-PubSub/test/cmd_string_test.go:773–830  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

771}
772
773func TestGetSet(t *testing.T) {
774 server.Clear()
775 c, err := proto.Dial(server.Addr())
776 ok(t, err)
777 defer c.Close()
778 s := server.Direct()
779
780 // Existing key
781 {
782 s.Set("foo", "bar")
783 mustDo(t, c,
784 "GETSET", "foo", "baz",
785 proto.String("bar"),
786 )
787 s.CheckGet(t, "foo", "baz")
788 }
789
790 // New key
791 {
792 mustNil(t, c,
793 "GETSET", "bar", "bak",
794 )
795 s.CheckGet(t, "bar", "bak")
796 }
797
798 // TTL needs to be cleared
799 {
800 s.Set("one", "two")
801 s.SetTTL("one", time.Second*1234)
802 mustDo(t, c,
803 "GETSET", "one", "three",
804 proto.String("two"),
805 )
806 s.CheckGet(t, "bar", "bak")
807 equals(t, time.Duration(0), s.TTL("one"))
808 }
809
810 // Wrong type of existing key
811 {
812 s.HSet("wrong", "aap", "noot")
813 mustDo(t, c,
814 "GETSET", "wrong", "key",
815 proto.Error(msgWrongType),
816 )
817 }
818
819 // Wrong usage
820 {
821 mustDo(t, c,
822 "GETSET",
823 proto.Error(errWrongNumber("getset")),
824 )
825 mustDo(t, c,
826 "GETSET", "spurious", "arguments", "here",
827 proto.Error(errWrongNumber("getset")),
828 )
829 }
830}

Callers

nothing calls this directly

Calls 13

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
mustNilFunction · 0.70
equalsFunction · 0.70
errWrongNumberFunction · 0.70

Tested by

no test coverage detected