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

fix(createCollection): Db.createCollection should pass readConcern to new collection #2026

Merged
merged 13 commits into from
Jun 21, 2019
32 changes: 7 additions & 25 deletions test/functional/readconcern_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,26 @@ describe('ReadConcern', function() {
metadata: { requires: { topology: 'replicaset', mongodb: '>= 3.2' } },

test: function(done) {
var listener = require('../..').instrument(function(err) {
test.equal(null, err);
});

// Contains all the apm events
var started = [];
let started = [];
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved
// Get a new instance
var configuration = this.configuration;
var client = configuration.newClient(
let configuration = this.configuration;
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved
const client = configuration.newClient(
{ w: 1 },
{ poolSize: 1, readConcern: { level: 'local' } }
{ poolSize: 1, readConcern: { level: 'local' }, monitorCommands: true }
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved
);

client.connect(function(err, client) {
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved
expect(err).to.not.exist;

var db = client.db(configuration.db);
let db = client.db(configuration.db);
test.deepEqual({ level: 'local' }, db.s.readConcern);
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved

// Get a collection using createCollection
var collection = db.createCollection('readConcernCollection');
let collection = db.createCollection('readConcernCollection');
// Validate readConcern
test.deepEqual({ level: 'local' }, collection.s.readConcern);
// Perform a find using the readConcern
listener.on('started', function(event) {
if (event.commandName === 'find') started.push(event);
});

// Execute find
collection.find().toArray(function(err) {
test.equal(null, err);
test.equal(1, started.length);
test.deepEqual({ level: 'local' }, started[0].command.readConcern);

listener.uninstrument();
client.close();
done();
});
expect(test).to.deep.equal({ level: 'local' }, collection.s.readConcern);
rosemaryy marked this conversation as resolved.
Show resolved Hide resolved
});
}
});
Expand Down