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

Function TestSortedSetPopMin

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

*func TestZunionstore(t *testing.T) { server.Clear() c, err := proto.Dial(server.Addr()) ok(t, err) defer c.Close() s := server.Direct() s.ZAdd("h1", 1.0, "field1") s.ZAdd("h1", 2.0, "field2") s.ZAdd("h2", 1.0, "field1") s.ZAdd("h2", 2.0, "field2") t.Run("simple case", func(t *testing.T)

(t *testing.T)

Source from the content-addressed store, hash-verified

1771*/
1772// Test ZPOPMIN
1773func TestSortedSetPopMin(t *testing.T) {
1774 server.Clear()
1775 c, err := proto.Dial(server.Addr())
1776 ok(t, err)
1777 defer c.Close()
1778 s := server.Direct()
1779
1780 s.ZAdd("z", 1, "one")
1781 s.ZAdd("z", 2, "two")
1782 s.ZAdd("z", 2, "zwei")
1783 s.ZAdd("z", 3, "three")
1784 s.ZAdd("z", 3, "drei")
1785 s.ZAdd("z", math.Inf(+1), "inf")
1786
1787 mustDo(t, c,
1788 "ZPOPMIN", "z", "2",
1789 proto.Strings("one", "1", "two", "2"),
1790 )
1791
1792 // Get one - without count
1793 mustDo(t, c,
1794 "ZPOPMIN", "z",
1795 proto.Strings("zwei", "2"),
1796 )
1797
1798 // weird cases.
1799 mustDo(t, c,
1800 "ZPOPMIN", "z", "-100",
1801 proto.Strings(),
1802 )
1803
1804 // Nonexistent key
1805 mustDo(t, c,
1806 "ZPOPMIN", "nosuch", "1",
1807 proto.Strings(),
1808 )
1809
1810 // Get more than exist
1811 mustDo(t, c,
1812 "ZPOPMIN", "z", "100",
1813 proto.Strings("drei", "3", "three", "3", "inf", "inf"),
1814 )
1815
1816 t.Run("errors", func(t *testing.T) {
1817 mustDo(t, c,
1818 "ZPOPMIN",
1819 proto.Error(errWrongNumber("zpopmin")),
1820 )
1821 mustDo(t, c,
1822 "ZPOPMIN", "set", "noint",
1823 proto.Error(msgInvalidInt),
1824 )
1825 mustDo(t, c,
1826 "ZPOPMIN", "set", "1", "toomany",
1827 proto.Error(msgSyntaxError),
1828 )
1829
1830 s.Set("str", "value")

Callers

nothing calls this directly

Calls 12

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected