Skip to content

Commit 16a6567

Browse files
committed
Added some test to trigger getMore and killcursor commands
1 parent 5c82805 commit 16a6567

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

test/functional/cursor_tests.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,67 @@ exports.cursorShouldBeAbleToResetOnToArrayRunningQueryAgain = {
3838
}
3939
}
4040

41+
/**
42+
* @ignore
43+
* @api private
44+
*/
45+
exports['cursor should close after first next operation'] = {
46+
// Add a tag that our runner can trigger on
47+
// in this case we are setting that node needs to be higher than 0.10.X to run
48+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl'] } },
49+
50+
// The actual test we wish to run
51+
test: function(configuration, test) {
52+
var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1});
53+
db.open(function(err, db) {
54+
db.createCollection('close_on_next', function(err, collection) {
55+
56+
collection.insert([{'a':1}, {'a':1}, {'a':1}], configuration.writeConcernMax(), function(err, ids) {
57+
var cursor = collection.find({});
58+
cursor.batchSize(2);
59+
cursor.next(function(err, d) {
60+
test.equal(null, err);
61+
62+
cursor.close();
63+
db.close();
64+
test.done();
65+
});
66+
});
67+
});
68+
});
69+
}
70+
}
71+
72+
/**
73+
* @ignore
74+
* @api private
75+
*/
76+
exports['cursor should trigger getMore'] = {
77+
// Add a tag that our runner can trigger on
78+
// in this case we are setting that node needs to be higher than 0.10.X to run
79+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl'] } },
80+
81+
// The actual test we wish to run
82+
test: function(configuration, test) {
83+
var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1});
84+
db.open(function(err, db) {
85+
db.createCollection('trigger_get_more', function(err, collection) {
86+
87+
collection.insert([{'a':1}, {'a':1}, {'a':1}], configuration.writeConcernMax(), function(err, ids) {
88+
var cursor = collection.find({});
89+
cursor.batchSize(2);
90+
cursor.toArray(function(err, docs) {
91+
test.equal(null, err);
92+
93+
db.close();
94+
test.done();
95+
});
96+
});
97+
});
98+
});
99+
}
100+
}
101+
41102
/**
42103
* @ignore
43104
* @api private

0 commit comments

Comments
 (0)