@@ -753,6 +753,51 @@ def test_xpending_with_range_options
753
753
assert_equal 1 , actual [ 2 ] [ 'count' ]
754
754
end
755
755
756
+ def test_xpending_with_range_and_idle_options
757
+ target_version "6.2" do
758
+ redis . xadd ( 's1' , { f : 'v1' } , id : '0-1' )
759
+ redis . xgroup ( :create , 's1' , 'g1' , '$' )
760
+ redis . xadd ( 's1' , { f : 'v2' } , id : '0-2' )
761
+ redis . xadd ( 's1' , { f : 'v3' } , id : '0-3' )
762
+ redis . xreadgroup ( 'g1' , 'c1' , 's1' , '>' )
763
+
764
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 )
765
+ assert_equal 2 , actual . size
766
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 , idle : 10 )
767
+ assert_equal 0 , actual . size
768
+ sleep 0.1
769
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 , idle : 10 )
770
+ assert_equal 2 , actual . size
771
+
772
+ redis . xadd ( 's1' , { f : 'v4' } , id : '0-4' )
773
+ redis . xreadgroup ( 'g1' , 'c2' , 's1' , '>' )
774
+
775
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 , idle : 1000 )
776
+ assert_equal 0 , actual . size
777
+
778
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 )
779
+ assert_equal 3 , actual . size
780
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 , idle : 10 )
781
+ assert_equal 2 , actual . size
782
+ sleep 0.01
783
+ actual = redis . xpending ( 's1' , 'g1' , '-' , '+' , 10 , idle : 10 )
784
+ assert_equal 3 , actual . size
785
+
786
+ assert_equal '0-2' , actual [ 0 ] [ 'entry_id' ]
787
+ assert_equal 'c1' , actual [ 0 ] [ 'consumer' ]
788
+ assert_equal true , actual [ 0 ] [ 'elapsed' ] >= 0
789
+ assert_equal 1 , actual [ 0 ] [ 'count' ]
790
+ assert_equal '0-3' , actual [ 1 ] [ 'entry_id' ]
791
+ assert_equal 'c1' , actual [ 1 ] [ 'consumer' ]
792
+ assert_equal true , actual [ 1 ] [ 'elapsed' ] >= 0
793
+ assert_equal 1 , actual [ 1 ] [ 'count' ]
794
+ assert_equal '0-4' , actual [ 2 ] [ 'entry_id' ]
795
+ assert_equal 'c2' , actual [ 2 ] [ 'consumer' ]
796
+ assert_equal true , actual [ 2 ] [ 'elapsed' ] >= 0
797
+ assert_equal 1 , actual [ 2 ] [ 'count' ]
798
+ end
799
+ end
800
+
756
801
def test_xpending_with_range_and_consumer_options
757
802
redis . xadd ( 's1' , { f : 'v1' } , id : '0-1' )
758
803
redis . xgroup ( :create , 's1' , 'g1' , '$' )
0 commit comments