@@ -336,6 +336,26 @@ describe('The node_redis client', function () {
336
336
} ) ;
337
337
} ) ;
338
338
339
+ it ( 'should retry all commands even if the offline queue is disabled' , function ( done ) {
340
+ var bclient = redis . createClient ( {
341
+ parser : parser ,
342
+ enableOfflineQueue : false ,
343
+ retryUnfulfilledCommands : true
344
+ } ) ;
345
+ bclient . once ( 'ready' , function ( ) {
346
+ bclient . blpop ( 'blocking list 2' , 5 , function ( err , value ) {
347
+ assert . strictEqual ( value [ 0 ] , 'blocking list 2' ) ;
348
+ assert . strictEqual ( value [ 1 ] , 'initial value' ) ;
349
+ bclient . end ( true ) ;
350
+ done ( err ) ;
351
+ } ) ;
352
+ setTimeout ( function ( ) {
353
+ bclient . stream . destroy ( ) ;
354
+ client . rpush ( 'blocking list 2' , 'initial value' , helper . isNumber ( 1 ) ) ;
355
+ } , 100 ) ;
356
+ } ) ;
357
+ } ) ;
358
+
339
359
} ) ;
340
360
341
361
describe ( '.end' , function ( ) {
@@ -650,6 +670,7 @@ describe('The node_redis client', function () {
650
670
} ) ;
651
671
652
672
monitorClient . on ( 'monitor' , function ( time , args , rawOutput ) {
673
+ assert . strictEqual ( monitorClient . monitoring , true ) ;
653
674
responses . push ( args ) ;
654
675
assert ( utils . monitor_regex . test ( rawOutput ) , rawOutput ) ;
655
676
if ( responses . length === 6 ) {
@@ -670,6 +691,7 @@ describe('The node_redis client', function () {
670
691
} ) ;
671
692
672
693
monitorClient . MONITOR ( function ( err , res ) {
694
+ assert . strictEqual ( monitorClient . monitoring , true ) ;
673
695
assert . strictEqual ( res . inspect ( ) , new Buffer ( 'OK' ) . inspect ( ) ) ;
674
696
client . mget ( 'hello' , new Buffer ( 'world' ) ) ;
675
697
} ) ;
@@ -688,6 +710,7 @@ describe('The node_redis client', function () {
688
710
client . MONITOR ( helper . isString ( 'OK' ) ) ;
689
711
client . mget ( 'hello' , 'world' ) ;
690
712
client . on ( 'monitor' , function ( time , args , rawOutput ) {
713
+ assert . strictEqual ( client . monitoring , true ) ;
691
714
assert ( utils . monitor_regex . test ( rawOutput ) , rawOutput ) ;
692
715
assert . deepEqual ( args , [ 'mget' , 'hello' , 'world' ] ) ;
693
716
if ( i ++ === 2 ) {
@@ -708,6 +731,7 @@ describe('The node_redis client', function () {
708
731
assert . deepEqual ( res , [ 'OK' , [ null , null ] ] ) ;
709
732
} ) ;
710
733
client . on ( 'monitor' , function ( time , args , rawOutput ) {
734
+ assert . strictEqual ( client . monitoring , true ) ;
711
735
assert ( utils . monitor_regex . test ( rawOutput ) , rawOutput ) ;
712
736
assert . deepEqual ( args , [ 'mget' , 'hello' , 'world' ] ) ;
713
737
if ( i ++ === 2 ) {
@@ -719,20 +743,22 @@ describe('The node_redis client', function () {
719
743
} ) ;
720
744
} ) ;
721
745
722
- it ( 'monitor does not activate if the command could not be processed properly' , function ( done ) {
746
+ it ( 'monitor activates even if the command could not be processed properly after a reconnect ' , function ( done ) {
723
747
client . MONITOR ( function ( err , res ) {
724
748
assert . strictEqual ( err . code , 'UNCERTAIN_STATE' ) ;
725
749
} ) ;
726
750
client . on ( 'error' , function ( err ) { } ) ; // Ignore error here
727
751
client . stream . destroy ( ) ;
752
+ var end = helper . callFuncAfter ( done , 2 ) ;
728
753
client . on ( 'monitor' , function ( time , args , rawOutput ) {
729
- done ( new Error ( 'failed' ) ) ; // Should not be activated
754
+ assert . strictEqual ( client . monitoring , true ) ;
755
+ end ( ) ;
730
756
} ) ;
731
757
client . on ( 'reconnecting' , function ( ) {
732
758
client . get ( 'foo' , function ( err , res ) {
733
759
assert ( ! err ) ;
734
- assert . strictEqual ( client . monitoring , false ) ;
735
- setTimeout ( done , 10 ) ; // The monitor command might be returned a tiny bit later
760
+ assert . strictEqual ( client . monitoring , true ) ;
761
+ end ( ) ;
736
762
} ) ;
737
763
} ) ;
738
764
} ) ;
0 commit comments