Skip to content

Commit e7d3324

Browse files
committed
add test cases
1 parent aad0938 commit e7d3324

File tree

12 files changed

+4114
-684
lines changed

12 files changed

+4114
-684
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Topcoder - Community Processor
1+
# Topcoder - Community Processor
22

33
## Dependencies
44

@@ -19,6 +19,7 @@ The following parameters can be set in config files or in env variables:
1919
- KAFKA_CLIENT_CERT_KEY: Kafka connection private key, optional; default value is undefined;
2020
if not provided, then SSL connection is not used, direct insecure connection is used;
2121
if provided, it can be either path to private key file or private key content
22+
- KAFKA_GROUP_ID: Kafka group id, default value is 'tc-member-group-processor-group'
2223
- KAFKA_TOPICS: Kafka topics to listen, default value is ['member.action.profile.trait.create', 'member.action.profile.trait.update', 'member.action.profile.trait.delete']
2324
- TC_API_BASE_URL: TC API base URL, default value is 'https://api.topcoder.com'
2425
- AUTH0_URL: Auth0 URL, used to get TC M2M token
@@ -32,6 +33,12 @@ export AUTH0_URL="<Auth0 URL>"
3233
export AUTH0_CLIENT_ID="<Auth0 Client ID>"
3334
export AUTH0_CLIENT_SECRET="<Auth0 Client Secret>"
3435

36+
Configuration for test is at config/test.js:
37+
38+
- MOCK_M2M_API_PORT: the port of mock M2M api, default value: 4000
39+
- MOCK_GROUP_API_PORT: the port of mock group api, default value: 4001
40+
- WAIT_TIME: wait time used in test, default is 1500 or 1.5 second
41+
3542
## Local Kafka setup
3643

3744
- `http://kafka.apache.org/quickstart` contains details to setup and manage Kafka server,
@@ -108,6 +115,10 @@ docker-compose up
108115
]
109116
},
110117
"createdBy": 23225544,
111-
- "updatedAt": "8/15/18 6:22 PM"
118+
"updatedAt": "8/15/18 6:22 PM"
112119
}
113-
```
120+
```
121+
122+
## Testing
123+
- Run `npm run test` to execute unit tests.
124+
- RUN `npm run e2e` to execute e2e tests.

config/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module.exports = {
1212
KAFKA_CLIENT_CERT: process.env.KAFKA_CLIENT_CERT,
1313
KAFKA_CLIENT_CERT_KEY: process.env.KAFKA_CLIENT_CERT_KEY,
1414

15+
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID || 'tc-member-group-processor-group',
16+
1517
KAFKA_TOPICS: (process.env.KAFKA_TOPICS && process.env.KAFKA_TOPICS.split(',')) ||
1618
['member.action.profile.trait.create', 'member.action.profile.trait.update', 'member.action.profile.trait.delete'],
1719

config/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* The test configuration.
3+
*/
4+
const MOCK_M2M_API_PORT = 4000
5+
const MOCK_GROUP_API_PORT = 4001
6+
7+
module.exports = {
8+
LOG_LEVEL: 'debug',
9+
MOCK_M2M_API_PORT,
10+
MOCK_GROUP_API_PORT,
11+
// The M2M API URL
12+
TC_API_BASE_URL: `http://localhost:${MOCK_GROUP_API_PORT}`,
13+
// configuration for TC M2M API
14+
AUTH0_URL: `http://localhost:${MOCK_M2M_API_PORT}/m2m`,
15+
AUTH0_AUDIENCE: 'https://www.topcoder.com',
16+
AUTH0_CLIENT_ID: 'test_id',
17+
AUTH0_CLIENT_SECRET: 'test_secret',
18+
WAIT_TIME: 1500
19+
}

0 commit comments

Comments
 (0)