diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Update.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Update.ts index f7d81553..57d6ea7c 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Update.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Update.ts @@ -14,7 +14,6 @@ import { getDocumentCollection, limitFive, onlyReturnTimestamps, - // writeLockReferencedDocuments, insertMeadowlarkIdOnConcurrencyCollection, getConcurrencyCollection, deleteMeadowlarkIdOnConcurrencyCollection, diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Upsert.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Upsert.ts index de7ed27d..02d6c26f 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Upsert.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/src/repository/Upsert.ts @@ -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, diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Delete.test.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Delete.test.ts index 6c0b6b2d..fb5c3168 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Delete.test.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Delete.test.ts @@ -25,7 +25,6 @@ import { getNewClient, insertMeadowlarkIdOnConcurrencyCollection, onlyReturnId, - // writeLockReferencedDocuments, } from '../../../src/repository/Db'; import { validateReferences, @@ -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); } diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Update.test.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Update.test.ts index a5fbca8e..22305fea 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Update.test.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/integration/locking/Update.test.ts @@ -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 @@ -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); } diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Delete.test.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Delete.test.ts index 4620c98a..0d0dbef0 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Delete.test.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Delete.test.ts @@ -8,7 +8,7 @@ describe('given a transaction on a resource', () => { let mongoClientMock = {}; let deleteOneMock = jest.fn(); const error = { - codeName: 'WriteConflict', + code: 11000, }; beforeAll(() => { diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Update.test.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Update.test.ts index b7dd6cb5..f932b172 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Update.test.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Update.test.ts @@ -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); }); @@ -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); }); @@ -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); }); diff --git a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Upsert.test.ts b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Upsert.test.ts index 61af41ac..552c1c69 100644 --- a/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Upsert.test.ts +++ b/Meadowlark-js/backends/meadowlark-mongodb-backend/test/repository/Upsert.test.ts @@ -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); }); @@ -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); }); @@ -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); });