Skip to content

Commit

Permalink
Removes unnecesary comments. locking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJGapCR committed Oct 13, 2023
1 parent 42e6039 commit 536374e
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
getDocumentCollection,
limitFive,
onlyReturnTimestamps,
// writeLockReferencedDocuments,
insertMeadowlarkIdOnConcurrencyCollection,
getConcurrencyCollection,
deleteMeadowlarkIdOnConcurrencyCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Logger, Config } from '@edfi/meadowlark-utilities';
import retry from 'async-retry';
import { MeadowlarkDocument, meadowlarkDocumentFrom } from '../model/MeadowlarkDocument';
import {
// writeLockReferencedDocuments,
asUpsert,
limitFive,
getDocumentCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
getNewClient,
insertMeadowlarkIdOnConcurrencyCollection,
onlyReturnId,
// writeLockReferencedDocuments,
} from '../../../src/repository/Db';
import {
validateReferences,
Expand Down Expand Up @@ -223,9 +222,7 @@ describe('given a delete concurrent with an insert referencing the to-be-deleted

await mongoDocumentCollection.deleteOne({ _id: schoolMeadowlarkId }, { session: deleteSession });
} catch (e) {
expect(e).toMatchInlineSnapshot(
`[MongoBulkWriteError: E11000 duplicate key error collection: meadowlark.concurrency index: meadowlarkId_1_documentUuid_1 dup key: { meadowlarkId: "Qw5FvPdKxAXWnGght_4HOBmlPt_xB_pA20fKyQ", documentUuid: "2edb604f-eab0-412c-a242-508d6529214d" }]`,
);
expect(e.message).toContain('E11000 duplicate key error collection');
expect(e.name).toBe('MongoBulkWriteError');
expect(e.code).toBe(11000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import { upsertDocument } from '../../../src/repository/Upsert';
import { setupConfigForIntegration } from '../Config';
import { ConcurrencyDocument } from '../../../src/model/ConcurrencyDocument';

jest.setTimeout(120_000);

const documentUuid = '2edb604f-eab0-412c-a242-508d6529214d' as DocumentUuid;

// A bunch of setup stuff
Expand Down Expand Up @@ -226,9 +224,7 @@ describe('given an upsert (update) concurrent with an insert referencing the to-

await mongoDocumentCollection.replaceOne({ _id: schoolMeadowlarkId }, schoolDocument, asUpsert(updateSession));
} catch (e) {
expect(e).toMatchInlineSnapshot(
`[MongoBulkWriteError: E11000 duplicate key error collection: meadowlark.concurrency index: meadowlarkId_1_documentUuid_1 dup key: { meadowlarkId: "Qw5FvPdKxAXWnGght_4HOBmlPt_xB_pA20fKyQ", documentUuid: "2edb604f-eab0-412c-a242-508d6529214d" }]`,
);
expect(e.message).toContain('E11000 duplicate key error collection');
expect(e.name).toBe('MongoBulkWriteError');
expect(e.code).toBe(11000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('given a transaction on a resource', () => {
let mongoClientMock = {};
let deleteOneMock = jest.fn();
const error = {
codeName: 'WriteConflict',
code: 11000,
};

beforeAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries greater than zero has been configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
jest.spyOn(utilities.Config, 'get').mockReturnValue(retryNumberOfTimes);
result = await updateDocumentByDocumentUuid(newUpdateRequest(), mongoClientMock as any);
});
Expand All @@ -79,7 +78,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries equal to zero has been configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
jest.spyOn(utilities.Config, 'get').mockReturnValue(0);
result = await updateDocumentByDocumentUuid(newUpdateRequest(), mongoClientMock as any);
});
Expand All @@ -95,7 +93,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries was not configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
result = await updateDocumentByDocumentUuid(newUpdateRequest(), mongoClientMock as any);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries greater than zero has been configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
jest.spyOn(utilities.Config, 'get').mockReturnValue(retryNumberOfTimes);
result = await upsertDocument(newUpsertRequest(), mongoClientMock as any);
});
Expand All @@ -70,7 +69,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries equal to zero has been configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
jest.spyOn(utilities.Config, 'get').mockReturnValue(0);
result = await upsertDocument(newUpsertRequest(), mongoClientMock as any);
});
Expand All @@ -86,7 +84,6 @@ describe('given a transaction on a resource', () => {

describe('given that a number of retries was not configured', () => {
beforeAll(async () => {
// jest.spyOn(DB, 'writeLockReferencedDocuments').mockImplementationOnce(async () => Promise.resolve());
result = await upsertDocument(newUpsertRequest(), mongoClientMock as any);
});

Expand Down

0 comments on commit 536374e

Please sign in to comment.