Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE-3008: Adding test for cursor cloning removing session #2723

Merged
merged 1 commit into from Feb 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Comment on lines +4689 to +4691
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(clonedCursor.cursorState.session).to.not.exist;
cursor.close();
done();
expect(clonedCursor.cursorState).to.not.have.property('session');
cursor.close(done);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I already fixed it and force pushed. ;)

});
});
});
});
});
});