Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hrm-domain/hrm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@tech-matters/twilio-worker-auth": "^1.0.0",
"@tech-matters/types": "^1.0.0",
"@tech-matters/database-connect": "^1.0.0",
"aws-sdk": "^2.1231.0",
"aws-sdk": "^2.1693.0",
"cors": "^2.8.5",
"date-fns": "^2.28.0",
"debug": "^4.1.1",
Expand Down
9 changes: 5 additions & 4 deletions hrm-domain/hrm-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"description": "The easiest way to run the tests locally is to run the test DB in docker.",
"scripts": {
"localstack:setup": "cd ../../ && npm run && npm run start:localstack",
"start": "cd dist && node ./www",
"start:job-processor": "cd dist && node ./jobProcessor",
"start:job-cleanup": "cd dist && node ./jobCleanup",
Expand All @@ -18,9 +19,9 @@
"docker:compose:test:down": "docker compose -f ../../test-support/docker-compose-service-test.yml down",
"test": "run-s test:service",
"test:run:watch": "cross-env AWS_REGION=us-east-1 CI=true TWILIO_ACCOUNT_SID=ACxxx TWILIO_AUTH_TOKEN=xxxxxx RDS_PASSWORD=postgres jest --maxWorkers=1 --forceExit --watch",
"test:service": "cross-env POSTGRES_PORT=5433 run-s -c docker:compose:test:up test:service:ci:migrate test:service:run docker:compose:test:down",
"test:service:run": "cross-env AWS_REGION=us-east-1 SSM_ENDPOINT=http://mock-ssm/ SNS_ENDPOINT=http://mock-sns/ jest --verbose --maxWorkers=1 --forceExit service-tests",
"test:service:ci": "run-s test:service:ci:migrate test:service:ci:run",
"test:service": "cross-env POSTGRES_PORT=5433 run-s -c localstack:setup docker:compose:test:up test:service:ci:migrate test:service:run docker:compose:test:down",
"test:service:run": "cross-env AWS_REGION=us-east-1 SQS_ENDPOINT=http://localhost:4566 SSM_ENDPOINT=http://mock-ssm/ SNS_ENDPOINT=http://mock-sns/ jest --verbose --maxWorkers=1 --forceExit service-tests/profiles",
"test:service:ci": "run-s test:service:ci:migrate test:service:ci:run",
"test:service:ci:migrate": "cross-env CI=true RDS_PASSWORD=postgres node ./db-migrate",
"test:service:ci:run": "cross-env AWS_REGION=us-east-1 SSM_ENDPOINT=http://mock-ssm/ SNS_ENDPOINT=http://mock-sns/ CI=true TWILIO_ACCOUNT_SID=ACxxx TWILIO_AUTH_TOKEN=xxxxxx RDS_PASSWORD=postgres jest --verbose --maxWorkers=1 --forceExit --coverage service-tests",
"test:coverage": "run-s docker:compose:test:up test:service:ci:migrate test:coverage:run docker:compose:test:down",
Expand Down Expand Up @@ -72,7 +73,7 @@
"@types/http-errors": "^2.0.1",
"@types/lodash": "^4.14.191",
"@types/supertest": "^2.0.12",
"aws-sdk": "^2.1353.0",
"aws-sdk": "^2.1693.0",
"chalk": "^4.0.0",
"cross-env": "^7.0.3",
"date-fns": "^2.30.0",
Expand Down
35 changes: 2 additions & 33 deletions hrm-domain/hrm-service/service-tests/sqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import sqslite from 'sqslite';
// eslint-disable-next-line import/no-extraneous-dependencies
import { SQS } from 'aws-sdk';

export const setupTestQueues = (queueNames: string[]) => {
const sqsService = sqslite({});
const sqsClient = new SQS({
endpoint: `http://localhost:${process.env.LOCAL_SQS_PORT}`,
endpoint: process.env.SQS_ENDPOINT,
});
beforeAll(() => sqsService.listen({ port: parseInt(process.env.LOCAL_SQS_PORT!) }));
afterAll(() => sqsService.close());
beforeEach(async () => {
await Promise.all(
queueNames.map(async queueName =>
Expand All @@ -37,34 +32,8 @@ export const setupTestQueues = (queueNames: string[]) => {
),
);
});
afterEach(async () => {
await Promise.allSettled(
queueNames.map(async queueName => {
try {
const resp = await sqsClient
.getQueueUrl({
QueueName: queueName,
})
.promise();
const testQueueUrl = resp.QueueUrl;
await sqsClient
.deleteQueue({
QueueUrl: testQueueUrl.toString(),
})
.promise();
} catch (err) {
console.error(
expect.getState().currentTestName,
'\nError deleting queue',
queueName,
err,
);
}
}),
);
});

return {
sqsService,
sqsClient,
};
};
Loading
Loading