Skip to content

Commit 1eeb2cc

Browse files
committed
chore: remove outdated core cursor tests
This removes the cursor tests migrated from the core/native merger, any test which was not already covered by the `AbstractCursor` tests was migrated. NODE-2812
1 parent 98ae02c commit 1eeb2cc

File tree

2 files changed

+38
-388
lines changed

2 files changed

+38
-388
lines changed

test/functional/abstract_cursor.test.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('AbstractCursor', function () {
2222
before(
2323
withClientV2((client, done) => {
2424
const docs = [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }];
25-
const coll = client.db().collection('find_cursor');
25+
const coll = client.db().collection('abstract_cursor');
2626
const tryNextColl = client.db().collection('try_next');
2727
coll.drop(() => tryNextColl.drop(() => coll.insertMany(docs, done)));
2828
})
@@ -35,7 +35,7 @@ describe('AbstractCursor', function () {
3535
const commands = [];
3636
client.on('commandStarted', filterForCommands(['getMore'], commands));
3737

38-
const coll = client.db().collection('find_cursor');
38+
const coll = client.db().collection('abstract_cursor');
3939
const cursor = coll.find({}, { batchSize: 2 });
4040
this.defer(() => cursor.close());
4141

@@ -49,14 +49,46 @@ describe('AbstractCursor', function () {
4949
);
5050
});
5151

52+
context('#readBufferedDocuments', function () {
53+
it(
54+
'should support reading buffered documents',
55+
withClientV2(function (client, done) {
56+
const coll = client.db().collection('abstract_cursor');
57+
const cursor = coll.find({}, { batchSize: 5 });
58+
59+
cursor.next((err, doc) => {
60+
expect(err).to.not.exist;
61+
expect(doc).property('a').to.equal(1);
62+
expect(cursor.bufferedCount()).to.equal(4);
63+
64+
// Read the buffered Count
65+
cursor.readBufferedDocuments(cursor.bufferedCount());
66+
67+
// Get the next item
68+
cursor.next((err, doc) => {
69+
expect(err).to.not.exist;
70+
expect(doc).to.exist;
71+
72+
cursor.next((err, doc) => {
73+
expect(err).to.not.exist;
74+
expect(doc).to.be.null;
75+
76+
done();
77+
});
78+
});
79+
});
80+
})
81+
);
82+
});
83+
5284
context('#close', function () {
5385
it(
5486
'should send a killCursors command when closed before completely iterated',
5587
withClientV2(function (client, done) {
5688
const commands = [];
5789
client.on('commandStarted', filterForCommands(['killCursors'], commands));
5890

59-
const coll = client.db().collection('find_cursor');
91+
const coll = client.db().collection('abstract_cursor');
6092
const cursor = coll.find({}, { batchSize: 2 });
6193
cursor.next(err => {
6294
expect(err).to.not.exist;
@@ -75,7 +107,7 @@ describe('AbstractCursor', function () {
75107
const commands = [];
76108
client.on('commandStarted', filterForCommands(['killCursors'], commands));
77109

78-
const coll = client.db().collection('find_cursor');
110+
const coll = client.db().collection('abstract_cursor');
79111
const cursor = coll.find({}, { batchSize: 2 });
80112
cursor.toArray(err => {
81113
expect(err).to.not.exist;
@@ -95,7 +127,7 @@ describe('AbstractCursor', function () {
95127
const commands = [];
96128
client.on('commandStarted', filterForCommands(['killCursors'], commands));
97129

98-
const coll = client.db().collection('find_cursor');
130+
const coll = client.db().collection('abstract_cursor');
99131
const cursor = coll.find({}, { batchSize: 2 });
100132
cursor.close(err => {
101133
expect(err).to.not.exist;
@@ -110,7 +142,7 @@ describe('AbstractCursor', function () {
110142
it(
111143
'should iterate each document in a cursor',
112144
withClientV2(function (client, done) {
113-
const coll = client.db().collection('find_cursor');
145+
const coll = client.db().collection('abstract_cursor');
114146
const cursor = coll.find({}, { batchSize: 2 });
115147

116148
const bag = [];

0 commit comments

Comments
 (0)