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

Function TestSortedSetRem

IceFireDB-PubSub/test/cmd_sorted_set_test.go:665–725  ·  view source on GitHub ↗

Test ZREM

(t *testing.T)

Source from the content-addressed store, hash-verified

663
664// Test ZREM
665func TestSortedSetRem(t *testing.T) {
666 server.Clear()
667 c, err := proto.Dial(server.Addr())
668 ok(t, err)
669 defer c.Close()
670 s := server.Direct()
671
672 s.ZAdd("z", 1, "one")
673 s.ZAdd("z", 2, "two")
674 s.ZAdd("z", 2, "zwei")
675
676 // Simple delete
677 {
678 mustDo(t, c,
679 "ZREM", "z", "two", "zwei", "nosuch",
680 proto.Int(2),
681 )
682 assert(t, s.Exists("z"), "key is there")
683 }
684 // Delete the last member
685 {
686 must1(t, c,
687 "ZREM", "z", "one",
688 )
689 assert(t, !s.Exists("z"), "key is gone")
690 }
691 // Nonexistent key
692 must0(t, c,
693 "ZREM", "nosuch", "member",
694 )
695
696 // Direct
697 {
698 s.ZAdd("z2", 1, "one")
699 s.ZAdd("z2", 2, "two")
700 s.ZAdd("z2", 2, "zwei")
701 gone, err := s.ZRem("z2", "two")
702 ok(t, err)
703 assert(t, gone, "member gone")
704 members, err := s.ZMembers("z2")
705 ok(t, err)
706 equals(t, []string{"one", "zwei"}, members)
707 }
708
709 t.Run("errors", func(t *testing.T) {
710 mustDo(t, c,
711 "ZREM",
712 proto.Error(errWrongNumber("zrem")),
713 )
714 mustDo(t, c,
715 "ZREM", "set",
716 proto.Error(errWrongNumber("zrem")),
717 )
718 // Wrong type of key
719 s.Set("str", "value")
720 mustDo(t, c,
721 "ZREM", "str", "aap",
722 proto.Error(msgWrongType),

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected