Skip to content

Commit

Permalink
test: Adding test for cursor cloning removing session (#2723)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran authored Feb 2, 2021
1 parent 6314f5a commit 2fffb52
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/functional/cursor.test.js
Original file line number Diff line number Diff line change
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 2fffb52

Please sign in to comment.