@@ -205,3 +205,53 @@ exports['Should correctly return failing Promise when array passed into insertOn
205205 } ) ;
206206 }
207207}
208+
209+ exports [ 'Should correctly execute unordered bulk operation in promise form' ] = {
210+ metadata : { requires : { promises :true , topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
211+
212+ // The actual test we wish to run
213+ test : function ( configuration , test ) {
214+ var MongoClient = configuration . require . MongoClient ;
215+ var url = configuration . url ( ) ;
216+ url = url . indexOf ( '?' ) != - 1
217+ ? f ( '%s&%s' , url , 'maxPoolSize=100' )
218+ : f ( '%s?%s' , url , 'maxPoolSize=100' ) ;
219+
220+ MongoClient . connect ( url ) . then ( function ( db ) {
221+ var bulk = db . collection ( 'unordered_bulk_promise_form' ) . initializeUnorderedBulkOp ( { w :1 } ) ;
222+ bulk . insert ( { a :1 } ) ;
223+ bulk . execute ( ) . then ( function ( r ) {
224+ test . ok ( r ) ;
225+ test . deepEqual ( { w :1 } , bulk . s . writeConcern ) ;
226+
227+ db . close ( ) ;
228+ test . done ( ) ;
229+ } ) ;
230+ } ) ;
231+ }
232+ }
233+
234+ exports [ 'Should correctly execute ordered bulk operation in promise form' ] = {
235+ metadata : { requires : { promises :true , topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
236+
237+ // The actual test we wish to run
238+ test : function ( configuration , test ) {
239+ var MongoClient = configuration . require . MongoClient ;
240+ var url = configuration . url ( ) ;
241+ url = url . indexOf ( '?' ) != - 1
242+ ? f ( '%s&%s' , url , 'maxPoolSize=100' )
243+ : f ( '%s?%s' , url , 'maxPoolSize=100' ) ;
244+
245+ MongoClient . connect ( url ) . then ( function ( db ) {
246+ var bulk = db . collection ( 'unordered_bulk_promise_form' ) . initializeOrderedBulkOp ( { w :1 } ) ;
247+ bulk . insert ( { a :1 } ) ;
248+ bulk . execute ( ) . then ( function ( r ) {
249+ test . ok ( r ) ;
250+ test . deepEqual ( { w :1 } , bulk . s . writeConcern ) ;
251+
252+ db . close ( ) ;
253+ test . done ( ) ;
254+ } ) ;
255+ } ) ;
256+ }
257+ }
0 commit comments