From ceec576fba68a4093ed76e8def4f3d7b487f62cb Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 4 May 2022 10:58:48 +0100 Subject: [PATCH] tests for allowDiskUse --- .../crud/find_cursor_methods.test.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/integration/crud/find_cursor_methods.test.js b/test/integration/crud/find_cursor_methods.test.js index abaaf5bbaa..4cce162b3f 100644 --- a/test/integration/crud/find_cursor_methods.test.js +++ b/test/integration/crud/find_cursor_methods.test.js @@ -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(); + }); + }) + ); + }); });