Skip to content

Commit 2fffb52

Browse files
authored
test: Adding test for cursor cloning removing session (#2723)
1 parent 6314f5a commit 2fffb52

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/functional/cursor.test.js

+26
Original file line numberDiff line numberDiff line change
@@ -4668,4 +4668,30 @@ describe('Cursor', function() {
46684668
});
46694669
});
46704670
});
4671+
4672+
describe('#clone', function() {
4673+
it('removes the existing session from the cloned cursor', function(done) {
4674+
const configuration = this.configuration;
4675+
const client = configuration.newClient();
4676+
client.connect(error => {
4677+
expect(error).to.not.exist;
4678+
this.defer(() => client.close());
4679+
4680+
const docs = [{ name: 'test1' }, { name: 'test2' }];
4681+
const coll = client.db(configuration.db).collection('cursor_session_mapping');
4682+
coll.insertMany(docs, err => {
4683+
expect(err).to.not.exist;
4684+
const cursor = coll.find({}, { batchSize: 1 });
4685+
cursor.next((er, doc) => {
4686+
expect(er).to.not.exist;
4687+
expect(doc).to.exist;
4688+
const clonedCursor = cursor.clone();
4689+
expect(clonedCursor.cursorState.session).to.not.exist;
4690+
cursor.close();
4691+
done();
4692+
});
4693+
});
4694+
});
4695+
});
4696+
});
46714697
});

0 commit comments

Comments
 (0)