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

Function TestLrem

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

Source from the content-addressed store, hash-verified

537}
538
539func TestLrem(t *testing.T) {
540 server.Clear()
541 c, err := proto.Dial(server.Addr())
542 ok(t, err)
543 defer c.Close()
544 s := server.Direct()
545 // Reverse
546 {
547 s.Push("l", "aap", "noot", "mies", "vuur", "noot", "noot")
548 must1(t, c,
549 "LREM", "l", "-1", "noot",
550 )
551 l, err := s.List("l")
552 ok(t, err)
553 equals(t, []string{"aap", "noot", "mies", "vuur", "noot"}, l)
554 }
555 // Normal
556 {
557 s.Push("l2", "aap", "noot", "mies", "vuur", "noot", "noot")
558 mustDo(t, c,
559 "LREM", "l2", "2", "noot",
560 proto.Int(2),
561 )
562 l, err := s.List("l2")
563 ok(t, err)
564 equals(t, []string{"aap", "mies", "vuur", "noot"}, l)
565 }
566
567 // All
568 {
569 s.Push("l3", "aap", "noot", "mies", "vuur", "noot", "noot")
570 mustDo(t, c,
571 "LREM", "l3", "0", "noot",
572 proto.Int(3),
573 )
574 l, err := s.List("l3")
575 ok(t, err)
576 equals(t, []string{"aap", "mies", "vuur"}, l)
577 }
578
579 // All
580 {
581 s.Push("l4", "aap", "noot", "mies", "vuur", "noot", "noot")
582 mustDo(t, c,
583 "LREM", "l4", "200", "noot",
584 proto.Int(3),
585 )
586 l, err := s.List("l4")
587 ok(t, err)
588 equals(t, []string{"aap", "mies", "vuur"}, l)
589 }
590
591 // Delete key on empty list
592 {
593 s.Push("l5", "noot", "noot", "noot")
594 mustDo(t, c,
595 "LREM", "l5", "99", "noot",
596 proto.Int(3),

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
must1Function · 0.70
equalsFunction · 0.70
mustDoFunction · 0.70
must0Function · 0.70

Tested by

no test coverage detected