Skip to content

Commit 3f587ed

Browse files
committed
try again
1 parent 4840e8f commit 3f587ed

11 files changed

Lines changed: 115 additions & 22 deletions

File tree

configurator/config/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ const dotenv = require('dotenv');
22
const path = require('path');
33

44
const isDocker = process.env.DOCKER_ENV === 'true';
5+
const isTest = process.env.NODE_ENV === 'integration';
56

6-
if (!isDocker) {
7-
const envPath = path.resolve(__dirname, '../../.env');
7+
if (!isDocker && !isTest) {
8+
const envPath = path.resolve(__dirname, '../.env');
89
const res = dotenv.config({ path: envPath });
910

1011
if (res.error) {
@@ -23,8 +24,8 @@ const getEnv = (key) => {
2324
};
2425

2526
const OPENHIM_API_URL = getEnv('OPENHIM_API_URL');
26-
const OPENHIM_API_USERNAME = getEnv('OPENHIM_ROOT_USERNAME');
27-
const OPENHIM_API_PASSWORD = getEnv('OPENHIM_ROOT_PASSWORD');
27+
const OPENHIM_API_USERNAME = getEnv('OPENHIM_USERNAME');
28+
const OPENHIM_API_PASSWORD = getEnv('OPENHIM_PASSWORD');
2829
const OPENHIM_CLIENT_PASSWORD = getEnv('OPENHIM_CLIENT_PASSWORD');
2930
const OPENHIM_USER_PASSWORD = getEnv('OPENHIM_USER_PASSWORD');
3031

configurator/env.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
COUCHDB_USER=admin
2+
COUCHDB_PASSWORD=password
3+
OPENHIM_API_URL=https://openhim-core:8080
4+
OPENHIM_PASSWORD=openhim-password
5+
OPENHIM_USERNAME=root@openhim.org
6+
OPENHIM_CLIENT_PASSWORD=interop-password
7+
OPENHIM_USER_PASSWORD=interop-password

docker/docker-compose.mediator.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ services:
77
ports:
88
- "6000:6000"
99
env_file:
10-
- ../.env
10+
- ../mediator/.env
1111
environment:
1212
- DOCKER_ENV=true
1313
depends_on:
1414
- configurator
1515
restart: 'unless-stopped'
1616
networks:
1717
- cht-net
18-
18+
1919
configurator:
2020
build:
2121
context: ../
2222
dockerfile: ./configurator/Dockerfile
2323
env_file:
24-
- ../.env
24+
- ../configurator/.env
2525
environment:
2626
- DOCKER_ENV=true
2727
networks:

mediator/config/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as dotenv from 'dotenv';
22
import path from 'path';
33

44
const isDocker = process.env.DOCKER_ENV === 'true';
5+
const isTest = process.env.NODE_ENV === 'integration';
56

6-
if (!isDocker) {
7-
const envPath = path.resolve(__dirname, '../../.env');
7+
if (!isDocker && !isTest) {
8+
const envPath = path.resolve(__dirname, '../.env');
89
const res = dotenv.config({
910
path: envPath
1011
});
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
OPENHIM_USERNAME=interop@openhim.org
22
OPENHIM_PASSWORD=interop-password
33
OPENHIM_API_URL=https://openhim-core:8080
4-
OPENHIM_ROOT_USERNAME=root@openhim.org
5-
OPENHIM_ROOT_PASSWORD=openhim-password
6-
OPENHIM_USER_PASSWORD=interop-password
7-
OPENHIM_CLIENT_PASSWORD=interop-password
84
PORT=6000
95
FHIR_URL=http://openhim-core:5001/fhir
106
FHIR_USERNAME=interop-client
117
FHIR_PASSWORD=interop-password
12-
CHT_URL=http://nginx
13-
CHT_USERNAME=medic
8+
CHT_URL=https://nginx
9+
CHT_USERNAME=admin
1410
CHT_PASSWORD=password
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ module.exports = {
1111
testPathIgnorePatterns: [
1212
'<rootDir>/dist/',
1313
],
14-
setupFilesAfterEnv: ['./jest.setup.ts'],
1514
};

mediator/jest.e2e.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const baseConfig = require('./jest.base.config.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
displayName: 'e2e',
6+
testMatch: [
7+
'<rootDir>/test/**/*.spec.ts',
8+
],
9+
// Note: setupFilesAfterEnv is not included here
10+
};

mediator/jest.setup.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as dotenv from 'dotenv';
2-
31
jest.mock('dotenv', () => ({
42
config: jest.fn(() => {
53
// Set the environment variables you need for your tests

mediator/jest.unit.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const baseConfig = require('./jest.base.config.js');
2+
3+
module.exports = {
4+
...baseConfig,
5+
displayName: 'unit',
6+
testMatch: [
7+
'<rootDir>/src/**/*.spec.ts',
8+
'!<rootDir>/test/**/*',
9+
],
10+
setupFilesAfterEnv: ['./jest.setup.ts'],
11+
};

mediator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test:watch": "jest --watch",
1212
"coverage": "jest --coverage",
1313
"clean": "rm -rf ./dist",
14-
"unit-test": "jest src/",
14+
"unit-test": "jest --config ./jest.unit.config.js",
1515
"e2e-test": "test/e2e-test.sh"
1616
},
1717
"repository": {

0 commit comments

Comments
 (0)