Skip to content

Commit

Permalink
Update applyWriteConcern.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored Jul 20, 2023
1 parent dea8aa6 commit cdadc2b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions test/helpers/applyWriteConcern.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,10 @@ describe('applyWriteConcern', function() {
after(async function() {
await db.close();
});
it('should not overwrite user specified writeConcern options gh-13592', async function() {
it('should not overwrite user specified writeConcern options (gh-13592)', async function() {
const options = { writeConcern: { w: 'majority' } };
const testSchema = new mongoose.Schema({ name: String }, { writeConcern: { w: 0 } });
const Test = db.model('Test', testSchema);
await Test.create({ name: 'Test Testerson' });
applyWriteConcern(testSchema, options);
assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options);
await Test.deleteMany({}, options);
assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options);
await Test.deleteMany({});
/**
* Because no options were passed in, it is using the schema level writeConcern options.
* However, because we are ensuring that user specified options are not being overwritten,
* this is the only reasonable way to test this case as our options object should not match the schema options.
*/
assert.deepStrictEqual({ writeConcern: { w: 'majority' } }, options);
});
});

0 comments on commit cdadc2b

Please sign in to comment.