Skip to content

chore: remove outdated core cursor tests #2648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions test/functional/abstract_cursor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('AbstractCursor', function () {
before(
withClientV2((client, done) => {
const docs = [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }];
const coll = client.db().collection('find_cursor');
const coll = client.db().collection('abstract_cursor');
const tryNextColl = client.db().collection('try_next');
coll.drop(() => tryNextColl.drop(() => coll.insertMany(docs, done)));
})
Expand All @@ -35,7 +35,7 @@ describe('AbstractCursor', function () {
const commands = [];
client.on('commandStarted', filterForCommands(['getMore'], commands));

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

Expand All @@ -49,14 +49,46 @@ describe('AbstractCursor', function () {
);
});

context('#readBufferedDocuments', function () {
it(
'should support reading buffered documents',
withClientV2(function (client, done) {
const coll = client.db().collection('abstract_cursor');
const cursor = coll.find({}, { batchSize: 5 });

cursor.next((err, doc) => {
expect(err).to.not.exist;
expect(doc).property('a').to.equal(1);
expect(cursor.bufferedCount()).to.equal(4);

// Read the buffered Count
cursor.readBufferedDocuments(cursor.bufferedCount());

// Get the next item
cursor.next((err, doc) => {
expect(err).to.not.exist;
expect(doc).to.exist;

cursor.next((err, doc) => {
expect(err).to.not.exist;
expect(doc).to.be.null;

done();
});
});
});
})
);
});

context('#close', function () {
it(
'should send a killCursors command when closed before completely iterated',
withClientV2(function (client, done) {
const commands = [];
client.on('commandStarted', filterForCommands(['killCursors'], commands));

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

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

const coll = client.db().collection('find_cursor');
const coll = client.db().collection('abstract_cursor');
const cursor = coll.find({}, { batchSize: 2 });
cursor.close(err => {
expect(err).to.not.exist;
Expand All @@ -110,7 +142,7 @@ describe('AbstractCursor', function () {
it(
'should iterate each document in a cursor',
withClientV2(function (client, done) {
const coll = client.db().collection('find_cursor');
const coll = client.db().collection('abstract_cursor');
const cursor = coll.find({}, { batchSize: 2 });

const bag = [];
Expand Down
Loading