@@ -270,66 +270,70 @@ describe('Aggregation', function () {
270
270
} ) ;
271
271
} ) ;
272
272
273
- it ( 'should correctly return a cursor and call explain' , function ( done ) {
274
- const client = this . configuration . newClient ( { maxPoolSize : 1 } ) ,
275
- databaseName = this . configuration . db ;
276
-
277
- const db = client . db ( databaseName ) ;
278
- // Some docs for insertion
279
- const docs = [
280
- {
281
- title : 'this is my title' ,
282
- author : 'bob' ,
283
- posted : new Date ( ) ,
284
- pageViews : 5 ,
285
- tags : [ 'fun' , 'good' , 'fun' ] ,
286
- other : { foo : 5 } ,
287
- comments : [
288
- { author : 'joe' , text : 'this is cool' } ,
289
- { author : 'sam' , text : 'this is bad' }
290
- ]
291
- }
292
- ] ;
273
+ it (
274
+ 'should correctly return a cursor and call explain' ,
275
+ { requires : { mongodb : '<7.1.0' } } ,
276
+ function ( done ) {
277
+ const client = this . configuration . newClient ( { maxPoolSize : 1 } ) ,
278
+ databaseName = this . configuration . db ;
279
+
280
+ const db = client . db ( databaseName ) ;
281
+ // Some docs for insertion
282
+ const docs = [
283
+ {
284
+ title : 'this is my title' ,
285
+ author : 'bob' ,
286
+ posted : new Date ( ) ,
287
+ pageViews : 5 ,
288
+ tags : [ 'fun' , 'good' , 'fun' ] ,
289
+ other : { foo : 5 } ,
290
+ comments : [
291
+ { author : 'joe' , text : 'this is cool' } ,
292
+ { author : 'sam' , text : 'this is bad' }
293
+ ]
294
+ }
295
+ ] ;
293
296
294
- // Create a collection
295
- const collection = db . collection ( 'shouldCorrectlyDoAggWithCursorGet' ) ;
296
- // Insert the docs
297
- collection . insertMany ( docs , { writeConcern : { w : 1 } } , function ( err , result ) {
298
- expect ( result ) . to . exist ;
299
- expect ( err ) . to . not . exist ;
297
+ // Create a collection
298
+ const collection = db . collection ( 'shouldCorrectlyDoAggWithCursorGet' ) ;
299
+ // Insert the docs
300
+ collection . insertMany ( docs , { writeConcern : { w : 1 } } , function ( err , result ) {
301
+ expect ( result ) . to . exist ;
302
+ expect ( err ) . to . not . exist ;
300
303
301
- // Execute aggregate, notice the pipeline is expressed as an Array
302
- const cursor = collection . aggregate (
303
- [
304
- {
305
- $project : {
306
- author : 1 ,
307
- tags : 1
304
+ // Execute aggregate, notice the pipeline is expressed as an Array
305
+ const cursor = collection . aggregate (
306
+ [
307
+ {
308
+ $project : {
309
+ author : 1 ,
310
+ tags : 1
311
+ }
312
+ } ,
313
+ { $unwind : '$tags' } ,
314
+ {
315
+ $group : {
316
+ _id : { tags : '$tags' } ,
317
+ authors : { $addToSet : '$author' }
318
+ }
308
319
}
309
- } ,
310
- { $unwind : '$tags' } ,
320
+ ] ,
311
321
{
312
- $group : {
313
- _id : { tags : '$tags' } ,
314
- authors : { $addToSet : '$author' }
315
- }
322
+ cursor : { batchSize : 100 }
316
323
}
317
- ] ,
318
- {
319
- cursor : { batchSize : 100 }
320
- }
321
- ) ;
324
+ ) ;
322
325
323
- // Iterate over all the items in the cursor
324
- cursor . explain ( function ( err , result ) {
325
- expect ( err ) . to . not . exist ;
326
- expect ( result . stages ) . to . have . lengthOf . at . least ( 1 ) ;
327
- expect ( result . stages [ 0 ] ) . to . have . property ( '$cursor' ) ;
326
+ // Iterate over all the items in the cursor
327
+ cursor . explain ( function ( err , result ) {
328
+ expect ( err ) . to . not . exist ;
329
+ expect ( result . stages ) . to . have . lengthOf . at . least ( 1 ) ;
330
+ expect ( result . stages [ 0 ] ) . to . have . property ( '$cursor' ) ;
328
331
329
- client . close ( done ) ;
332
+ client . close ( done ) ;
333
+ } ) ;
330
334
} ) ;
331
- } ) ;
332
- } ) ;
335
+ }
336
+ ) . skipReason = 'TODO(NODE-5617): aggregate explain tests failing on latest servers' ;
333
337
334
338
it ( 'should correctly return a cursor with batchSize 1 and call next' , function ( done ) {
335
339
const client = this . configuration . newClient ( { w : 1 } , { maxPoolSize : 1 } ) ,
0 commit comments