Skip to content

Commit

Permalink
tests for allowDiskUse
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxb committed May 4, 2022
1 parent c573bd1 commit ceec576
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/integration/crud/find_cursor_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,46 @@ describe('Find Cursor', function () {
})
});
});

context('#allowDiskUse', function () {
it(
'should set allowDiskUse to true by default',
withClientV2(function (client, done) {
const commands = [];
client.on('commandStarted', filterForCommands(['find'], commands));

const coll = client.db().collection('abstract_cursor');
const cursor = coll.find({}, { sort: 'foo' });
cursor.allowDiskUse();
this.defer(() => cursor.close());

cursor.toArray(err => {
expect(err).to.not.exist;
expect(commands).to.have.length(1);
expect(commands[0].command.allowDiskUse).to.equal(true);
done();
});
})
);

it(
'should set allowDiskUse to false if specified',
withClientV2(function (client, done) {
const commands = [];
client.on('commandStarted', filterForCommands(['find'], commands));

const coll = client.db().collection('abstract_cursor');
const cursor = coll.find({}, { sort: 'foo' });
cursor.allowDiskUse(false);
this.defer(() => cursor.close());

cursor.toArray(err => {
expect(err).to.not.exist;
expect(commands).to.have.length(1);
expect(commands[0].command.allowDiskUse).to.equal(false);
done();
});
})
);
});
});

0 comments on commit ceec576

Please sign in to comment.