Skip to content

Commit a53fd2c

Browse files
committed
Moved generator based aggregation test to generator_based_tests.js
1 parent 6e8de4d commit a53fd2c

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

test/functional/aggregation_tests.js

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -826,45 +826,4 @@ exports['Should correctly handle ISODate date matches in aggregation framework']
826826
});
827827
// DOC_END
828828
}
829-
}
830-
831-
exports['should maintain batch size between calls to receive new batches'] = {
832-
metadata: {
833-
requires: { generators: true, topology: 'single' , node: ">6.0.0" }
834-
},
835-
836-
// The actual test we wish to run
837-
test: function(configure, test) {
838-
var co = require('co');
839-
840-
co(function*() {
841-
var instance = configure.newDbInstance({ w: 1 }, { poolSize: 1 });
842-
var db = yield instance.open();
843-
844-
var docs = [ { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 } ];
845-
var collection = db.collection('batchSizeContinue');
846-
yield collection.insertMany(docs, { w: 1 });
847-
var cursor = collection.aggregate([
848-
{ $match: { a: 1 } }, { $limit: 6 }
849-
], {
850-
cursor: { batchSize: 2 }
851-
});
852-
853-
var count = 0;
854-
while (yield cursor.hasNext()) {
855-
var data = yield cursor.next();
856-
test.equal(data.a, 1);
857-
858-
// ensure batch size is as specified
859-
test.equal(cursor.cursorState.documents.length, 2);
860-
count++;
861-
}
862-
863-
test.equal(count, 6);
864-
db.close();
865-
test.done();
866-
}).catch(err => {
867-
console.log(err)
868-
});
869-
}
870-
}
829+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
exports['should maintain batch size between calls to receive new batches'] = {
2+
metadata: {
3+
requires: { generators: true, topology: 'single' , node: ">6.0.0" }
4+
},
5+
6+
// The actual test we wish to run
7+
test: function(configure, test) {
8+
var co = require('co');
9+
10+
co(function*() {
11+
var instance = configure.newDbInstance({ w: 1 }, { poolSize: 1 });
12+
var db = yield instance.open();
13+
14+
var docs = [ { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }, { a: 1 } ];
15+
var collection = db.collection('batchSizeContinue');
16+
yield collection.insertMany(docs, { w: 1 });
17+
var cursor = collection.aggregate([
18+
{ $match: { a: 1 } }, { $limit: 6 }
19+
], {
20+
cursor: { batchSize: 2 }
21+
});
22+
23+
var count = 0;
24+
while (yield cursor.hasNext()) {
25+
var data = yield cursor.next();
26+
test.equal(data.a, 1);
27+
28+
// ensure batch size is as specified
29+
test.equal(cursor.cursorState.documents.length, 2);
30+
count++;
31+
}
32+
33+
test.equal(count, 6);
34+
db.close();
35+
test.done();
36+
}).catch(err => {
37+
console.log(err)
38+
});
39+
}
40+
}

test/runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ try {
364364
testFiles.push('/test/functional/buffering_proxy_tests.js');
365365
testFiles.push('/test/functional/view_tests.js');
366366
testFiles.push('/test/functional/crud_spec_tests.js');
367+
testFiles.push('/test/functional/generator_based_tests.js');
367368
} catch(err) {}
368369

369370
// Add all the tests to run

0 commit comments

Comments
 (0)