Skip to content

Commit

Permalink
test: Adding test for cursor cloning removing session
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Jan 29, 2021
1 parent 8082c89 commit b0bf9b4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/functional/cursor.test.js
Expand Up @@ -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();
});
});
});
});
});
});

0 comments on commit b0bf9b4

Please sign in to comment.