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

Function TestLindex

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

Source from the content-addressed store, hash-verified

387}
388
389func TestLindex(t *testing.T) {
390 server.Clear()
391 c, err := proto.Dial(server.Addr())
392 ok(t, err)
393 defer c.Close()
394 s := server.Direct()
395 s.Push("l", "aap", "noot", "mies", "vuur")
396
397 mustDo(t, c,
398 "LINDEX", "l", "0",
399 proto.String("aap"),
400 )
401 mustDo(t, c,
402 "LINDEX", "l", "1",
403 proto.String("noot"),
404 )
405 mustDo(t, c,
406 "LINDEX", "l", "3",
407 proto.String("vuur"),
408 )
409
410 mustNil(t, c, "LINDEX", "l", "3000") // Too many
411
412 mustDo(t, c,
413 "LINDEX", "l", "-1",
414 proto.String("vuur"),
415 )
416
417 mustDo(t, c,
418 "LINDEX", "l", "-2",
419 proto.String("mies"),
420 )
421
422 mustNil(t, c, "LINDEX", "l", "-400") // Too big
423
424 // Non existing key
425 mustNil(t, c, "LINDEX", "nonexisting", "400")
426
427 t.Run("errors", func(t *testing.T) {
428 // Wrong type of key
429 mustOK(t, c, "SET", "str", "value")
430 mustDo(t, c,
431 "LINDEX", "str", "1",
432 proto.Error(msgWrongType),
433 )
434
435 // Not an integer
436 mustDo(t, c,
437 "LINDEX", "l", "noint",
438 proto.Error("ERR value is not an integer or out of range"),
439 )
440 // Too many arguments
441 mustDo(t, c,
442 "LINDEX", "str", "l", "foo",
443 proto.Error("ERR wrong number of arguments for 'lindex' command"),
444 )
445 })
446}

Callers

nothing calls this directly

Calls 12

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringFunction · 0.92
ErrorFunction · 0.92
okFunction · 0.70
mustDoFunction · 0.70
mustNilFunction · 0.70
mustOKFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected