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

Function TestRpushx

IceFireDB-Redis-Proxy/test/cmd_list_test.go:893–953  ·  view source on GitHub ↗

*func TestRpoplpush(t *testing.T) { server.Clear() c, err := proto.Dial(server.Addr()) ok(t, err) defer c.Close() s := server.Direct() s.Push("l", "aap", "noot", "mies") s.Push("l2", "vuur", "noot", "end") { mustDo(t, c, "RPOPLPUSH", "l", "l2", proto.String("mies"), ) s.CheckList

(t *testing.T)

Source from the content-addressed store, hash-verified

891}*/
892
893func TestRpushx(t *testing.T) {
894 server.Clear()
895 c, err := proto.Dial(server.Addr())
896 ok(t, err)
897 defer c.Close()
898 s := server.Direct()
899 // Simple cases
900 {
901 // No key key
902 must0(t, c,
903 "RPUSHX", "l", "value",
904 )
905 assert(t, !s.Exists("l"), "l doesn't exist")
906
907 s.Push("l", "aap", "noot")
908 mustDo(t, c,
909 "RPUSHX", "l", "mies",
910 proto.Int(3),
911 )
912
913 s.CheckList(t, "l", "aap", "noot", "mies")
914 }
915
916 // Push more.
917 {
918 must1(t, c,
919 "LPUSH", "l2", "aap1",
920 )
921 mustDo(t, c,
922 "RPUSHX", "l2", "aap2", "noot2", "mies2",
923 proto.Int(4),
924 )
925
926 mustDo(t, c,
927 "LRANGE", "l2", "0", "0",
928 proto.Strings("aap1"),
929 )
930
931 mustDo(t, c,
932 "LRANGE", "l2", "-1", "-1",
933 proto.Strings("mies2"),
934 )
935 }
936
937 t.Run("errors", func(t *testing.T) {
938 s.Push("src", "aap", "noot", "mies")
939 mustDo(t, c,
940 "RPUSHX",
941 proto.Error(errWrongNumber("rpushx")),
942 )
943 mustDo(t, c,
944 "RPUSHX", "l",
945 proto.Error(errWrongNumber("rpushx")),
946 )
947 s.Set("str", "string!")
948 mustDo(t, c,
949 "RPUSHX", "str", "value",
950 proto.Error(msgWrongType),

Callers

nothing calls this directly

Calls 15

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
must0Function · 0.70
assertFunction · 0.70
mustDoFunction · 0.70

Tested by

no test coverage detected