Skip to content

Commit

Permalink
Add function to clear validationCache to test validators
Browse files Browse the repository at this point in the history
  • Loading branch information
jleiva-gap committed Oct 31, 2023
1 parent efb7b6a commit 828d22c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Meadowlark-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
"test:lint:ts": "tsc -p . --noEmit",
"test:unit": "cross-env NODE_OPTIONS=--max-old-space-size=6144 LOG_LEVEL=warn jest --projects tests/config/unit",
"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",
"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",
"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",
"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",
"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",
"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",
"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",
"test:unit:coverage": "rimraf coverage.unit/ && npm run test:unit",
"test:unit:coverage:ci": "rimraf coverage.unit/ && npm run test:unit -- --maxWorkers=2 --ci",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ function getSchemaValidatorsFor(metaEdModel: TopLevelEntity): ResourceSchemaVali
return resourceValidators;
}

/**
* Function to delete all item from validatorCache for testing purposes.
*/
export function clearAllValidatorCache(): void {
validatorCache.clear();
}
/**
* Creates a new empty ResourceMatchResult object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { setupMockConfiguration } from '../../ConfigHelper';
import { UpsertResult } from '../../../src/message/UpsertResult';
import { UpdateResult } from '../../../src/message/UpdateResult';
import { DocumentUuid } from '../../../src/model/IdTypes';
import { clearAllValidatorCache } from '../../../src/metaed/MetaEdValidation';

let upsertResponse: FrontendResponse;
let updateResponse: FrontendResponse;
Expand Down Expand Up @@ -72,6 +73,7 @@ const frontendRequestUpdateAdditionalProperties: FrontendRequest = {

describe('given Allow Overposting equals to false', () => {
beforeAll(async () => {
clearAllValidatorCache();
setupMockConfiguration();
initializeLogging();
jest.spyOn(PluginLoader, 'getDocumentStore').mockReturnValue(NoDocumentStorePlugin);
Expand Down Expand Up @@ -151,6 +153,7 @@ describe('given Allow Overposting equals to false', () => {

describe('given Allow Overposting equals to true', () => {
beforeAll(async () => {
clearAllValidatorCache();
setupMockConfiguration();
initializeLogging();
jest.spyOn(PluginLoader, 'getDocumentStore').mockReturnValue(NoDocumentStorePlugin);
Expand Down

0 comments on commit 828d22c

Please sign in to comment.