@@ -38,6 +38,12 @@ describe("The 'multi' method", function () {
3838 done ( ) ;
3939 } ) ;
4040 } ) ;
41+
42+ it ( "reports an error if promisified" , function ( ) {
43+ return client . multi ( ) . execAsync ( ) . catch ( function ( err ) {
44+ assert ( err . message . match ( / T h e c o n n e c t i o n h a s a l r e a d y b e e n c l o s e d / ) ) ;
45+ } ) ;
46+ } ) ;
4147 } ) ;
4248
4349 describe ( "when connected" , function ( ) {
@@ -238,6 +244,22 @@ describe("The 'multi' method", function () {
238244 } ) ;
239245 } ) ;
240246
247+ it ( 'allows multiple commands to work the same as normal to be performed using a chaining API promisified' , function ( ) {
248+ return client . multi ( )
249+ . mset ( [ 'some' , '10' , 'keys' , '20' ] )
250+ . incr ( [ 'some' , helper . isNumber ( 11 ) ] )
251+ . incr ( [ 'keys' ] , helper . isNumber ( 21 ) )
252+ . mget ( 'some' , 'keys' )
253+ . execAsync ( )
254+ . then ( function ( replies ) {
255+ assert . equal ( 'OK' , replies [ 0 ] ) ;
256+ assert . equal ( 11 , replies [ 1 ] ) ;
257+ assert . equal ( 21 , replies [ 2 ] ) ;
258+ assert . equal ( 11 , replies [ 3 ] [ 0 ] . toString ( ) ) ;
259+ assert . equal ( 21 , replies [ 3 ] [ 1 ] . toString ( ) ) ;
260+ } ) ;
261+ } ) ;
262+
241263 it ( 'allows an array to be provided indicating multiple operations to perform' , function ( done ) {
242264 // test nested multi-bulk replies with nulls.
243265 client . multi ( [
@@ -299,6 +321,19 @@ describe("The 'multi' method", function () {
299321 } ) ;
300322 } ) ;
301323
324+ it ( 'reports multiple exceptions when they occur (while EXEC is running) promisified' , function ( ) {
325+ return client . multi ( ) . config ( "bar" ) . debug ( "foo" ) . eval ( "return {err='this is an error'}" , 0 ) . execAsync ( ) . then ( function ( reply ) {
326+ assert . strictEqual ( reply . length , 3 ) ;
327+ assert . equal ( reply [ 0 ] . code , 'ERR' ) ;
328+ assert . equal ( reply [ 0 ] . command , 'CONFIG' ) ;
329+ assert . equal ( reply [ 2 ] . code , undefined ) ;
330+ assert . equal ( reply [ 2 ] . command , 'EVAL' ) ;
331+ assert ( / ^ t h i s i s a n e r r o r / . test ( reply [ 2 ] . message ) ) ;
332+ assert ( / ^ E R R / . test ( reply [ 0 ] . message ) , "Error message should begin with ERR" ) ;
333+ assert ( / ^ E R R / . test ( reply [ 1 ] . message ) , "Error message should begin with ERR" ) ;
334+ } ) ;
335+ } ) ;
336+
302337 it ( 'reports multiple exceptions when they occur (while EXEC is running) and calls cb' , function ( done ) {
303338 var multi = client . multi ( ) ;
304339 multi . config ( "bar" , helper . isError ( ) ) ;
0 commit comments