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

Function TestLpop

IceFireDB-Redis-Proxy/test/cmd_list_test.go:207–281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func TestLpop(t *testing.T) {
208 server.Clear()
209 c, err := proto.Dial(server.Addr())
210 ok(t, err)
211 defer c.Close()
212 t.Run("single", func(t *testing.T) {
213 mustDo(t, c,
214 "LPUSH", "l", "aap", "noot", "mies",
215 proto.Int(3),
216 )
217
218 mustDo(t, c,
219 "LPOP", "l",
220 proto.String("mies"),
221 )
222
223 mustDo(t, c,
224 "LPOP", "l",
225 proto.String("noot"),
226 )
227
228 mustDo(t, c,
229 "LPOP", "l",
230 proto.String("aap"),
231 )
232
233 // Last element has been popped. Key is gone.
234 must0(t, c, "EXISTS", "l")
235
236 // Can pop non-existing keys just fine.
237 mustNil(t, c, "LPOP", "l")
238 })
239
240 t.Run("with count", func(t *testing.T) {
241 mustDo(t, c,
242 "LPUSH", "l2", "aap", "noot", "mies",
243 proto.Int(3),
244 )
245
246 mustDo(t, c,
247 "LPOP", "l2", "2",
248 proto.Strings("mies", "noot"),
249 )
250
251 mustDo(t, c,
252 "LPOP", "l2", "2",
253 proto.Strings("aap"),
254 )
255
256 mustDo(t, c,
257 "LPOP", "l2", "99",
258 proto.Nil,
259 )
260
261 mustDo(t, c,
262 "LPOP", "l2", "0",
263 proto.Nil,
264 )

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
IntFunction · 0.92
StringFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
mustDoFunction · 0.70
must0Function · 0.70
mustNilFunction · 0.70
mustOKFunction · 0.70

Tested by

no test coverage detected