From b0bf9b4bc89ccb41e8863fd7be39970a6e337c31 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 29 Jan 2021 15:29:51 +0100 Subject: [PATCH] test: Adding test for cursor cloning removing session --- test/functional/cursor.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/functional/cursor.test.js b/test/functional/cursor.test.js index 9b3588ff53..e745ebb1f3 100644 --- a/test/functional/cursor.test.js +++ b/test/functional/cursor.test.js @@ -4668,4 +4668,30 @@ describe('Cursor', function() { }); }); }); + + describe('#clone', function() { + it('removes the existing session from the cloned cursor', function(done) { + const configuration = this.configuration; + const client = configuration.newClient(); + client.connect(error => { + expect(error).to.not.exist; + this.defer(() => client.close()); + + const docs = [{ name: 'test1' }, { name: 'test2' }]; + const coll = client.db(configuration.db).collection('cursor_session_mapping'); + coll.insertMany(docs, err => { + expect(err).to.not.exist; + const cursor = coll.find({}, { batchSize: 1 }); + cursor.next((er, doc) => { + expect(er).to.not.exist; + expect(doc).to.exist; + const clonedCursor = cursor.clone(); + expect(clonedCursor.cursorState.session).to.not.exist; + cursor.close(); + done(); + }); + }); + }); + }); + }); });