Skip to content

Commit

Permalink
daria's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Mar 11, 2022
1 parent 3392dbf commit 019d7a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 0 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ declare global {
interface Test {
metadata: MongoDBMetadataUI;

/** @deprecated Attach spec to a test if you need access to it in a beforeEach hook, not recommended?? */
spec: Record<string, any>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Retryable Writes Spec Prose', () => {
.catch(error => error);

expect(error).to.exist;
expect(error).to.be.instanceOf(MongoServerError);
expect(error).that.is.instanceOf(MongoServerError);
expect(error).to.have.property('originalError').that.instanceOf(MongoError);
expect(error.originalError).to.have.property('code', 20);
expect(error).to.have.property(
Expand Down
23 changes: 13 additions & 10 deletions test/unit/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ describe('MongoErrors', () => {
// 8 - below server version 4.4
// 9 - above server version 4.4

const ABOVE_4_4 = 9;
const BELOW_4_4 = 8;

const tests: {
description: string;
result: boolean;
Expand All @@ -416,25 +419,25 @@ describe('MongoErrors', () => {
description: 'a plain error',
result: false,
error: new Error('do not retry me!'),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoError with no code nor label',
result: false,
error: new MongoError('do not retry me!'),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'network error',
result: true,
error: new MongoNetworkError('socket bad, try again'),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoWriteConcernError with no code nor label',
result: false,
error: new MongoWriteConcernError({ message: 'empty wc error' }),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoWriteConcernError with a random label',
Expand All @@ -443,31 +446,31 @@ describe('MongoErrors', () => {
{ message: 'random label' },
{ errorLabels: ['myLabel'] }
),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoWriteConcernError with a retryable code above server 4.4',
result: false,
error: new MongoWriteConcernError({}, { code: 262 }),
maxWireVersion: 9
maxWireVersion: ABOVE_4_4
},
{
description: 'a MongoWriteConcernError with a retryable code below server 4.4',
result: true,
error: new MongoWriteConcernError({}, { code: 262 }),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoWriteConcernError with a RetryableWriteError label below server 4.4',
result: true,
error: new MongoWriteConcernError({}, { errorLabels: ['RetryableWriteError'] }),
maxWireVersion: 8
maxWireVersion: BELOW_4_4
},
{
description: 'a MongoWriteConcernError with a RetryableWriteError label above server 4.4',
result: false,
error: new MongoWriteConcernError({}, { errorLabels: ['RetryableWriteError'] }),
maxWireVersion: 9
maxWireVersion: ABOVE_4_4
},
{
description: 'any MongoError with a RetryableWriteError label',
Expand All @@ -479,7 +482,7 @@ describe('MongoErrors', () => {
error.addErrorLabel('RetryableWriteError');
return error;
})(),
maxWireVersion: 9
maxWireVersion: ABOVE_4_4
}
];
for (const { description, result, error, maxWireVersion } of tests) {
Expand Down

0 comments on commit 019d7a7

Please sign in to comment.