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

Function TestLpushx

IceFireDB-PubSub/test/cmd_list_test.go:142–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestLpushx(t *testing.T) {
143 server.Clear()
144 c, err := proto.Dial(server.Addr())
145 ok(t, err)
146 defer c.Close()
147 s := server.Direct()
148 {
149 must0(t, c,
150 "LPUSHX", "l", "aap",
151 )
152 equals(t, false, s.Exists("l"))
153
154 // Create the list with a normal LPUSH
155 must1(t, c,
156 "LPUSH", "l", "noot",
157 )
158 equals(t, true, s.Exists("l"))
159
160 mustDo(t, c,
161 "LPUSHX", "l", "mies",
162 proto.Int(2),
163 )
164 equals(t, true, s.Exists("l"))
165 }
166
167 // Push more.
168 {
169 must1(t, c,
170 "LPUSH", "l2", "aap1",
171 )
172 mustDo(t, c,
173 "LPUSHX", "l2", "aap2", "noot2", "mies2",
174 proto.Int(4),
175 )
176
177 mustDo(t, c,
178 "LRANGE", "l2", "0", "0",
179 proto.Strings("mies2"),
180 )
181
182 mustDo(t, c,
183 "LRANGE", "l2", "-1", "-1",
184 proto.Strings("aap1"),
185 )
186 }
187
188 // Errors
189 {
190 mustDo(t, c,
191 "LPUSHX",
192 proto.Error("ERR wrong number of arguments for 'lpushx' command"),
193 )
194 mustDo(t, c,
195 "LPUSHX", "l",
196 proto.Error("ERR wrong number of arguments for 'lpushx' command"),
197 )
198
199 mustOK(t, c, "SET", "str", "value")

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
must0Function · 0.70
equalsFunction · 0.70
must1Function · 0.70
mustDoFunction · 0.70

Tested by

no test coverage detected