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

Function TestLset

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

Source from the content-addressed store, hash-verified

634}
635
636func TestLset(t *testing.T) {
637 server.Clear()
638 c, err := proto.Dial(server.Addr())
639 ok(t, err)
640 defer c.Close()
641 s := server.Direct()
642 s.Push("l", "aap", "noot", "mies", "vuur", "noot", "noot")
643 // Simple LSET
644 {
645 mustOK(t, c, "LSET", "l", "1", "noot!")
646 l, err := s.List("l")
647 ok(t, err)
648 equals(t, []string{"aap", "noot!", "mies", "vuur", "noot", "noot"}, l)
649 }
650
651 {
652 mustOK(t, c,
653 "LSET", "l", "-1", "noot?",
654 )
655 l, err := s.List("l")
656 ok(t, err)
657 equals(t, []string{"aap", "noot!", "mies", "vuur", "noot", "noot?"}, l)
658 }
659
660 // Out of range
661 mustDo(t, c,
662 "LSET", "l", "10000", "aap",
663 proto.Error("ERR index out of range"),
664 )
665 mustDo(t, c,
666 "LSET", "l", "-10000", "aap",
667 proto.Error("ERR index out of range"),
668 )
669
670 // Non existing key
671 mustDo(t, c,
672 "LSET", "nonexisting", "0", "aap",
673 proto.Error("ERR no such key"),
674 )
675
676 t.Run("errors", func(t *testing.T) {
677 mustDo(t, c,
678 "LSET",
679 proto.Error(errWrongNumber("lset")),
680 )
681 mustDo(t, c,
682 "LSET", "l",
683 proto.Error(errWrongNumber("lset")),
684 )
685 mustDo(t, c,
686 "LSET", "l", "1",
687 proto.Error(errWrongNumber("lset")),
688 )
689 mustDo(t, c,
690 "LSET", "l", "noint", "aap",
691 proto.Error("ERR value is not an integer or out of range"),
692 )
693 mustDo(t, c,

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