Skip to content

Commit d090947

Browse files
add regression test
1 parent c6fb958 commit d090947

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

test/integration/read-write-concern/write_concern.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,50 @@ describe('Write Concern', function () {
304304
}
305305
});
306306
});
307+
308+
describe('NODE-6763: write concern is still added with timeoutMS is set', function () {
309+
let client: MongoClient;
310+
let collection: Collection;
311+
const commands: CommandStartedEvent[] = [];
312+
beforeEach(async function () {
313+
client = this.configuration.newClient({}, { monitorCommands: true });
314+
client.on('commandStarted', filterForCommands('insert', commands));
315+
collection = client.db('foo').collection('bar');
316+
})
317+
318+
319+
afterEach(async function () {
320+
await client.close();
321+
commands.length = 0;
322+
})
323+
324+
context('when the write concern includes only timeouts', function () {
325+
it('the writeConcern is not added to the command.', async function () {
326+
await collection.insertOne({ name: 'john doe' }, { timeoutMS: 1000, writeConcern: { wtimeout: 1000 } });
327+
const [
328+
{
329+
command: {
330+
writeConcern
331+
}
332+
}
333+
] = commands;
334+
expect(writeConcern).not.to.exist;
335+
})
336+
})
337+
338+
context('when the write concern includes only non-timeout values (`w`)', function () {
339+
it('the writeConcern is added to the command.', async function () {
340+
await collection.insertOne({ name: 'john doe' }, { timeoutMS: 1000, writeConcern: { wtimeout: 1000, w: 'majority' } });
341+
const [
342+
{
343+
command: {
344+
writeConcern
345+
}
346+
}
347+
] = commands;
348+
expect(writeConcern).to.deep.equal({ w: 'majority' })
349+
})
350+
351+
})
352+
})
307353
});

test/unit/utils.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ describe('driver utils', function () {
403403
it('should be instanceof GeneratorFunction', () => {
404404
const list = new List<number>();
405405
// eslint-disable-next-line @typescript-eslint/no-empty-function
406-
expect(list[Symbol.iterator]).to.be.instanceOf(function* () {}.constructor);
406+
expect(list[Symbol.iterator]).to.be.instanceOf(function* () { }.constructor);
407407
});
408408

409409
it('should only run generator for the number of items in the list', () => {
@@ -857,9 +857,8 @@ describe('driver utils', function () {
857857
continue;
858858
}
859859

860-
const title = `comparing ${oid1} to ${oid2} returns ${
861-
result === 0 ? 'equal' : result === -1 ? 'less than' : 'greater than'
862-
}`;
860+
const title = `comparing ${oid1} to ${oid2} returns ${result === 0 ? 'equal' : result === -1 ? 'less than' : 'greater than'
861+
}`;
863862
// @ts-expect-error: not narrowed based on numeric result, but these values are correct
864863
it(title, () => expect(compareObjectId(oid1, oid2)).to.equal(result));
865864
}

0 commit comments

Comments
 (0)