@@ -294,4 +294,46 @@ describe('Find Cursor', function () {
294
294
} )
295
295
} ) ;
296
296
} ) ;
297
+
298
+ context ( '#allowDiskUse' , function ( ) {
299
+ it (
300
+ 'should set allowDiskUse to true by default' ,
301
+ withClientV2 ( function ( client , done ) {
302
+ const commands = [ ] ;
303
+ client . on ( 'commandStarted' , filterForCommands ( [ 'find' ] , commands ) ) ;
304
+
305
+ const coll = client . db ( ) . collection ( 'abstract_cursor' ) ;
306
+ const cursor = coll . find ( { } , { sort : 'foo' } ) ;
307
+ cursor . allowDiskUse ( ) ;
308
+ this . defer ( ( ) => cursor . close ( ) ) ;
309
+
310
+ cursor . toArray ( err => {
311
+ expect ( err ) . to . not . exist ;
312
+ expect ( commands ) . to . have . length ( 1 ) ;
313
+ expect ( commands [ 0 ] . command . allowDiskUse ) . to . equal ( true ) ;
314
+ done ( ) ;
315
+ } ) ;
316
+ } )
317
+ ) ;
318
+
319
+ it (
320
+ 'should set allowDiskUse to false if specified' ,
321
+ withClientV2 ( function ( client , done ) {
322
+ const commands = [ ] ;
323
+ client . on ( 'commandStarted' , filterForCommands ( [ 'find' ] , commands ) ) ;
324
+
325
+ const coll = client . db ( ) . collection ( 'abstract_cursor' ) ;
326
+ const cursor = coll . find ( { } , { sort : 'foo' } ) ;
327
+ cursor . allowDiskUse ( false ) ;
328
+ this . defer ( ( ) => cursor . close ( ) ) ;
329
+
330
+ cursor . toArray ( err => {
331
+ expect ( err ) . to . not . exist ;
332
+ expect ( commands ) . to . have . length ( 1 ) ;
333
+ expect ( commands [ 0 ] . command . allowDiskUse ) . to . equal ( false ) ;
334
+ done ( ) ;
335
+ } ) ;
336
+ } )
337
+ ) ;
338
+ } ) ;
297
339
} ) ;
0 commit comments