Skip to content

Commit

Permalink
test(collection): fixes test that failed to clean up client
Browse files Browse the repository at this point in the history
Fixes NODE-2115
  • Loading branch information
daprahamian authored Aug 14, 2019
1 parent 2051b57 commit c18b4ba
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions test/functional/collection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1250,24 +1250,34 @@ describe('Collection', function() {
});
});

it('should allow an empty replacement document for findOneAndReplace', function() {
const configuration = this.configuration;
const client = configuration.newClient({}, { w: 1 });

client.connect((err, client) => {
expect(err).to.be.null;
it('should allow an empty replacement document for findOneAndReplace', {
metadata: { requires: { mongodb: '>=3.0.0' } },
test: function(done) {
const configuration = this.configuration;
const client = configuration.newClient({}, { w: 1 });

const db = client.db(configuration.db);
const collection = db.collection('find_one_and_replace');
let finish = err => {
finish = () => {};
client.close(_err => done(err || _err));
};

collection.insertOne({ a: 1 }, err => {
client.connect((err, client) => {
expect(err).to.be.null;

expect(collection.findOneAndReplace.bind(collection, { a: 1 }, {})).to.not.throw();
});
const db = client.db(configuration.db);
const collection = db.collection('find_one_and_replace');

client.close();
});
collection.insertOne({ a: 1 }, err => {
expect(err).to.be.null;

try {
collection.findOneAndReplace({ a: 1 }, {}, finish);
} catch (e) {
finish(e);
}
});
});
}
});

it('should correctly update with pipeline', {
Expand Down

0 comments on commit c18b4ba

Please sign in to comment.