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

Function TestLinsert

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

Source from the content-addressed store, hash-verified

704}
705
706func TestLinsert(t *testing.T) {
707 server.Clear()
708 c, err := proto.Dial(server.Addr())
709 ok(t, err)
710 defer c.Close()
711 s := server.Direct()
712 s.Push("l", "aap", "noot", "mies", "vuur", "noot", "end")
713 // Before
714 {
715 mustDo(t, c,
716 "LINSERT", "l", "BEFORE", "noot", "!",
717 proto.Int(7),
718 )
719 l, err := s.List("l")
720 ok(t, err)
721 equals(t, []string{"aap", "!", "noot", "mies", "vuur", "noot", "end"}, l)
722 }
723
724 // After
725 {
726 mustDo(t, c,
727 "LINSERT", "l", "AFTER", "noot", "?",
728 proto.Int(8),
729 )
730 l, err := s.List("l")
731 ok(t, err)
732 equals(t, []string{"aap", "!", "noot", "?", "mies", "vuur", "noot", "end"}, l)
733 }
734
735 // Edge case before
736 {
737 mustDo(t, c,
738 "LINSERT", "l", "BEFORE", "aap", "[",
739 proto.Int(9),
740 )
741 l, err := s.List("l")
742 ok(t, err)
743 equals(t, []string{"[", "aap", "!", "noot", "?", "mies", "vuur", "noot", "end"}, l)
744 }
745
746 // Edge case after
747 {
748 mustDo(t, c,
749 "LINSERT", "l", "AFTER", "end", "]",
750 proto.Int(10),
751 )
752 l, err := s.List("l")
753 ok(t, err)
754 equals(t, []string{"[", "aap", "!", "noot", "?", "mies", "vuur", "noot", "end", "]"}, l)
755 }
756
757 // Non existing pivot
758 mustDo(t, c,
759 "LINSERT", "l", "before", "nosuch", "noot",
760 proto.Int(-1),
761 )
762
763 // Non existing key

Callers

nothing calls this directly

Calls 14

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
IntFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
equalsFunction · 0.70
must0Function · 0.70
errWrongNumberFunction · 0.70

Tested by

no test coverage detected