Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 828d22c

Browse files
committed
Add function to clear validationCache to test validators
1 parent efb7b6a commit 828d22c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Meadowlark-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
"test:lint:ts": "tsc -p . --noEmit",
5656
"test:unit": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects tests/config/unit",
5757
"test:integration": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-mongodb-backend/test/config/integration backends/meadowlark-opensearch-backend/test/config/integration backends/meadowlark-elasticsearch-backend/test/config/integration backends/meadowlark-postgresql-backend/test/config/integration packages/meadowlark-core/test/config/integration --runInBand",
58+
"test:integration:elasticsearch": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-elasticsearch-backend/test/config/integration --runInBand",
5859
"test:integration:meadowlark-core": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects packages/meadowlark-core/test/config/integration --runInBand",
5960
"test:integration:mongodb": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-mongodb-backend/test/config/integration --runInBand",
6061
"test:integration:opensearch": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-opensearch-backend/test/config/integration --runInBand",
61-
"test:integration:elasticsearch": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-elasticsearch-backend/test/config/integration --runInBand",
6262
"test:integration:postgresql": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects backends/meadowlark-postgresql-backend/test/config/integration --runInBand",
6363
"test:unit:coverage": "rimraf coverage.unit/ && npm run test:unit",
6464
"test:unit:coverage:ci": "rimraf coverage.unit/ && npm run test:unit -- --maxWorkers=2 --ci",

Meadowlark-js/packages/meadowlark-core/src/metaed/MetaEdValidation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ function getSchemaValidatorsFor(metaEdModel: TopLevelEntity): ResourceSchemaVali
5959
return resourceValidators;
6060
}
6161

62+
/**
63+
* Function to delete all item from validatorCache for testing purposes.
64+
*/
65+
export function clearAllValidatorCache(): void {
66+
validatorCache.clear();
67+
}
6268
/**
6369
* Creates a new empty ResourceMatchResult object
6470
*/

Meadowlark-js/packages/meadowlark-core/test/integration/metaed/MetaEdValidation.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { setupMockConfiguration } from '../../ConfigHelper';
1717
import { UpsertResult } from '../../../src/message/UpsertResult';
1818
import { UpdateResult } from '../../../src/message/UpdateResult';
1919
import { DocumentUuid } from '../../../src/model/IdTypes';
20+
import { clearAllValidatorCache } from '../../../src/metaed/MetaEdValidation';
2021

2122
let upsertResponse: FrontendResponse;
2223
let updateResponse: FrontendResponse;
@@ -72,6 +73,7 @@ const frontendRequestUpdateAdditionalProperties: FrontendRequest = {
7273

7374
describe('given Allow Overposting equals to false', () => {
7475
beforeAll(async () => {
76+
clearAllValidatorCache();
7577
setupMockConfiguration();
7678
initializeLogging();
7779
jest.spyOn(PluginLoader, 'getDocumentStore').mockReturnValue(NoDocumentStorePlugin);
@@ -151,6 +153,7 @@ describe('given Allow Overposting equals to false', () => {
151153

152154
describe('given Allow Overposting equals to true', () => {
153155
beforeAll(async () => {
156+
clearAllValidatorCache();
154157
setupMockConfiguration();
155158
initializeLogging();
156159
jest.spyOn(PluginLoader, 'getDocumentStore').mockReturnValue(NoDocumentStorePlugin);

0 commit comments

Comments
 (0)