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

Function TestLtrim

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

Source from the content-addressed store, hash-verified

478}
479
480func TestLtrim(t *testing.T) {
481 server.Clear()
482 c, err := proto.Dial(server.Addr())
483 ok(t, err)
484 defer c.Close()
485 s := server.Direct()
486 s.Push("l", "aap", "noot", "mies", "vuur")
487
488 {
489 mustOK(t, c, "LTRIM", "l", "0", "2")
490 l, err := s.List("l")
491 ok(t, err)
492 equals(t, []string{"aap", "noot", "mies"}, l)
493 }
494
495 // Delete key on empty list
496 {
497 mustOK(t, c, "LTRIM", "l", "0", "-99")
498 equals(t, false, s.Exists("l"))
499 }
500
501 // Not existing key
502 mustOK(t, c, "LTRIM", "nonexisting", "0", "1")
503
504 // Wrong type of key
505 t.Run("errors", func(t *testing.T) {
506 s.Set("str", "string!")
507 mustDo(t, c,
508 "LTRIM", "str", "0", "1",
509 proto.Error(msgWrongType),
510 )
511
512 mustDo(t, c,
513 "LTRIM", "l", "1", "2", "toomany",
514 proto.Error(errWrongNumber("ltrim")),
515 )
516 mustDo(t, c,
517 "LTRIM", "l", "1", "noint",
518 proto.Error("ERR value is not an integer or out of range"),
519 )
520 mustDo(t, c,
521 "LTRIM", "l", "noint", "1",
522 proto.Error("ERR value is not an integer or out of range"),
523 )
524 mustDo(t, c,
525 "LTRIM", "l", "1",
526 proto.Error(errWrongNumber("ltrim")),
527 )
528 mustDo(t, c,
529 "LTRIM", "l",
530 proto.Error(errWrongNumber("ltrim")),
531 )
532 mustDo(t, c,
533 "LTRIM",
534 proto.Error(errWrongNumber("ltrim")),
535 )
536 })
537}

Callers

nothing calls this directly

Calls 13

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustOKFunction · 0.70
equalsFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected