@@ -60,11 +60,13 @@ describe("The 'multi' method", function () {
60
60
61
61
it ( 'roles back a transaction when one command in a sequence of commands fails' , function ( done ) {
62
62
var multi1 , multi2 ;
63
+ var expected = helper . serverVersionAtLeast ( client , [ 2 , 6 , 5 ] ) ? helper . isError ( ) : function ( ) { } ;
63
64
64
65
// Provoke an error at queue time
65
66
multi1 = client . MULTI ( ) ;
66
67
multi1 . mset ( "multifoo" , "10" , "multibar" , "20" , helper . isString ( "OK" ) ) ;
67
- multi1 . set ( "foo2" ) ;
68
+
69
+ multi1 . set ( "foo2" , expected ) ;
68
70
multi1 . incr ( "multifoo" ) ;
69
71
multi1 . incr ( "multibar" ) ;
70
72
multi1 . exec ( function ( ) {
@@ -90,31 +92,33 @@ describe("The 'multi' method", function () {
90
92
} ) ;
91
93
92
94
it ( 'roles back a transaction when one command in an array of commands fails' , function ( done ) {
93
- // test nested multi-bulk replies
94
- client . multi ( [
95
- [ "mget" , "multifoo" , "multibar" , function ( err , res ) {
96
- assert . strictEqual ( 2 , res . length ) ;
97
- assert . strictEqual ( 0 , + res [ 0 ] ) ;
98
- assert . strictEqual ( 0 , + res [ 1 ] ) ;
99
- } ] ,
100
- [ "set" , "foo2" ] ,
101
- [ "incr" , "multifoo" ] ,
102
- [ "incr" , "multibar" ]
103
- ] ) . exec ( function ( err , replies ) {
104
- if ( helper . serverVersionAtLeast ( client , [ 2 , 6 , 5 ] ) ) {
105
- assert . notEqual ( err , null ) ;
106
- assert . equal ( replies , undefined ) ;
107
- } else {
108
- assert . strictEqual ( 2 , replies [ 0 ] . length ) ;
109
- assert . strictEqual ( null , replies [ 0 ] [ 0 ] ) ;
110
- assert . strictEqual ( null , replies [ 0 ] [ 1 ] ) ;
111
-
112
- assert . strictEqual ( "1" , replies [ 1 ] . toString ( ) ) ;
113
- assert . strictEqual ( "1" , replies [ 2 ] . toString ( ) ) ;
114
- }
115
-
116
- return done ( ) ;
117
- } ) ;
95
+ var expected = helper . serverVersionAtLeast ( client , [ 2 , 6 , 5 ] ) ? helper . isError ( ) : function ( ) { } ;
96
+
97
+ // test nested multi-bulk replies
98
+ client . multi ( [
99
+ [ "mget" , "multifoo" , "multibar" , function ( err , res ) {
100
+ assert . strictEqual ( 2 , res . length ) ;
101
+ assert . strictEqual ( 0 , + res [ 0 ] ) ;
102
+ assert . strictEqual ( 0 , + res [ 1 ] ) ;
103
+ } ] ,
104
+ [ "set" , "foo2" , expected ] ,
105
+ [ "incr" , "multifoo" ] ,
106
+ [ "incr" , "multibar" ]
107
+ ] ) . exec ( function ( err , replies ) {
108
+ if ( helper . serverVersionAtLeast ( client , [ 2 , 6 , 5 ] ) ) {
109
+ assert . notEqual ( err , null ) ;
110
+ assert . equal ( replies , undefined ) ;
111
+ } else {
112
+ assert . strictEqual ( 2 , replies [ 0 ] . length ) ;
113
+ assert . strictEqual ( null , replies [ 0 ] [ 0 ] ) ;
114
+ assert . strictEqual ( null , replies [ 0 ] [ 1 ] ) ;
115
+
116
+ assert . strictEqual ( "1" , replies [ 1 ] . toString ( ) ) ;
117
+ assert . strictEqual ( "1" , replies [ 2 ] . toString ( ) ) ;
118
+ }
119
+
120
+ return done ( ) ;
121
+ } ) ;
118
122
} ) ;
119
123
120
124
it ( 'handles multiple operations being applied to a set' , function ( done ) {
0 commit comments