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

Commit aaa143b

Browse files
#4 refactor to use submission api wrapper
1 parent 371d36d commit aaa143b

13 files changed

+1049
-220
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ The following parameters can be set in config files or in env variables:
2121
- REVIEW_TOPIC : Review topic, default value is 'submission.notification.score'
2222
- CREATE_SUBMISSION_TOPIC : create submission topic, default value is 'submission.notification.create'
2323
- UPDATE_SUBMISSION_TOPIC : update submission topic, default value is 'submission.notification.update'
24-
- REVIEW_API_URL: review api url, default is 'https://api.topcoder-dev.com/v5/reviews'
25-
- SUBMISSION_API_URL: submission api url, default is 'https://api.topcoder-dev.com/v5/submissions'
26-
- REVIEW_TYPE_API_URL: review type api url, default is 'https://api.topcoder-dev.com/v5/reviewTypes'
24+
- SUBMISSION_API_URL: submission api url, default is 'https://api.topcoder-dev.com/v5'
2725
- CHALLENGE_API_URL: challenge API URL, default is 'https://api.topcoder-dev.com/v4/challenges'
2826
- SCORECARD_API_URL: scorecard API URL, default is 'http://localhost:4000/scorecards'
27+
- BUS_API_URL: bus API URL, default is 'https://api.topcoder-dev.com/v5/bus/events'
2928
- AUTH0_URL: Auth0 URL, used to get TC M2M token
3029
- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token
3130
- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token
@@ -38,7 +37,6 @@ Also note that there is a `/health` endpoint that checks for the health of the a
3837

3938
Configuration for the tests is at `config/test.js`, only add such new configurations different from `config/default.js`
4039
- WAIT_TIME: wait time used in test, default is 2000 or 2 seconds
41-
- REVIEW_SUMMATION_API_URL: review summation api url, used to clear resource during testing, default is 'https://api.topcoder-dev.com/v5/reviewSummations'
4240

4341
## Local Kafka setup
4442

Verification.md

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -172,51 +172,38 @@ debug: Successfully processed message
172172

173173
## Unit test Coverage
174174

175-
129 passing (51s)
176-
177-
--------------------------------|----------|----------|----------|----------|-------------------|
178-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
179-
--------------------------------|----------|----------|----------|----------|-------------------|
180-
All files | 89.89 | 78.46 | 98.31 | 90.22 | |
181-
config | 100 | 97.22 | 100 | 100 | |
182-
default.js | 100 | 100 | 100 | 100 | |
183-
test.js | 100 | 75 | 100 | 100 | 6 |
184-
src/common | 84.62 | 53.85 | 95 | 86.52 | |
185-
helper.js | 69.23 | 50 | 85.71 | 75 | 18,91,92,93,95,96 |
186-
logger.js | 90.77 | 55 | 100 | 90.77 |31,55,60,84,98,118 |
187-
src/services | 89.32 | 78.85 | 100 | 89.11 | |
188-
ReviewProcessorService.js | 94.74 | 85 | 100 | 94.59 | 66,67 |
189-
SubmissionProcessorService.js | 86.15 | 75 | 100 | 85.94 |... 20,126,130,140 |
190-
test/unit | 91.89 | 75 | 100 | 91.86 | |
191-
review.processor.test.js | 91.87 | 70 | 100 | 91.8 |... 54,169,183,194 |
192-
submission.processor.test.js | 91.91 | 83.33 | 100 | 91.91 |... 64,178,191,202 |
193-
--------------------------------|----------|----------|----------|----------|-------------------|
194-
175+
129 passing (1s)
176+
177+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
178+
--------------------------------|----------|----------|----------|----------|-------------------
179+
All files | 91.63 | 79.63 | 100 | 91.46 |
180+
config | 100 | 96.67 | 100 | 100 |
181+
default.js | 100 | 100 | 100 | 100 |
182+
test.js | 100 | 50 | 100 | 100 | 6
183+
src/common | 92.13 | 57.69 | 100 | 91.95 |
184+
helper.js | 95.83 | 66.67 | 100 | 95.45 | 18
185+
logger.js | 90.77 | 55 | 100 | 90.77 |31,55,60,84,98,118
186+
src/services | 91.07 | 80.77 | 100 | 90.91 |
187+
ReviewProcessorService.js | 97.87 | 90 | 100 | 97.83 | 72
188+
SubmissionProcessorService.js | 86.15 | 75 | 100 | 85.94 |... 20,126,130,140
195189

196190

197191
## E2E test Coverage
198192

199-
136 passing (6m)
200-
201-
--------------------------------|----------|----------|----------|----------|-------------------|
202-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
203-
--------------------------------|----------|----------|----------|----------|-------------------|
204-
All files | 94.82 | 79.33 | 96.2 | 95.11 | |
205-
config | 100 | 97.22 | 100 | 100 | |
206-
default.js | 100 | 100 | 100 | 100 | |
207-
test.js | 100 | 75 | 100 | 100 | 6 |
208-
src | 93.88 | 71.43 | 90 | 93.75 | |
209-
app.js | 93.75 | 71.43 | 90 | 93.62 | 49,61,86 |
210-
bootstrap.js | 100 | 100 | 100 | 100 | |
211-
src/common | 84.62 | 61.54 | 95 | 86.52 | |
212-
helper.js | 69.23 | 50 | 85.71 | 75 | 18,91,92,93,95,96 |
213-
logger.js | 90.77 | 65 | 100 | 90.77 |31,55,60,84,98,118 |
214-
src/services | 89.32 | 78.85 | 100 | 89.11 | |
215-
ReviewProcessorService.js | 94.74 | 85 | 100 | 94.59 | 66,67 |
216-
SubmissionProcessorService.js | 86.15 | 75 | 100 | 85.94 |... 20,126,130,140 |
217-
test/e2e | 99.4 | 77.27 | 97.62 | 99.4 | |
218-
review.processor.test.js | 99.27 | 75 | 100 | 99.26 | 32 |
219-
submission.processor.test.js | 99.49 | 80 | 95.83 | 99.49 | 49 |
220-
--------------------------------|----------|----------|----------|----------|-------------------|
221-
222-
193+
136 passing (5m)
194+
195+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
196+
--------------------------------|----------|----------|----------|----------|-------------------
197+
All files | 92.06 | 80.33 | 97.14 | 91.9 |
198+
config | 100 | 96.67 | 100 | 100 |
199+
default.js | 100 | 100 | 100 | 100 |
200+
test.js | 100 | 50 | 100 | 100 | 6
201+
src | 93.88 | 71.43 | 90 | 93.75 |
202+
app.js | 93.75 | 71.43 | 90 | 93.62 | 49,61,86
203+
bootstrap.js | 100 | 100 | 100 | 100 |
204+
src/common | 92.13 | 65.38 | 100 | 91.95 |
205+
helper.js | 95.83 | 66.67 | 100 | 95.45 | 18
206+
logger.js | 90.77 | 65 | 100 | 90.77 |31,55,60,84,98,118
207+
src/services | 91.07 | 80.77 | 100 | 90.91 |
208+
ReviewProcessorService.js | 97.87 | 90 | 100 | 97.83 | 72
209+
SubmissionProcessorService.js | 86.15 | 75 | 100 | 85.94 |... 20,126,130,140

config/default.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ module.exports = {
2121
// Kafka topic related to update submission
2222
UPDATE_SUBMISSION_TOPIC: process.env.UPDATE_SUBMISSION_TOPIC || 'submission.notification.update',
2323

24-
REVIEW_API_URL: process.env.REVIEW_API_URL || 'https://api.topcoder-dev.com/v5/reviews',
25-
SUBMISSION_API_URL: process.env.SUBMISSION_API_URL || 'https://api.topcoder-dev.com/v5/submissions',
26-
REVIEW_TYPE_API_URL: process.env.REVIEW_TYPE_API_URL || 'https://api.topcoder-dev.com/v5/reviewTypes',
24+
SUBMISSION_API_URL: process.env.SUBMISSION_API_URL || 'https://api.topcoder-dev.com/v5',
25+
2726
CHALLENGE_API_URL: process.env.CHALLENGE_API_URL || 'https://api.topcoder-dev.com/v4/challenges',
2827
SCORECARD_API_URL: process.env.SCORECARD_API_URL || 'http://localhost:4000/scorecards',
2928
BUS_API_URL: process.env.BUS_API_URL || 'https://api.topcoder-dev.com/v5/bus/events',

config/test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
*/
44

55
module.exports = {
6-
WAIT_TIME: process.env.WAIT_TIME ? Number(process.env.WAIT_TIME) : 2000,
7-
REVIEW_SUMMATION_API_URL: process.env.REVIEW_SUMMATION_API_URL ||
8-
'https://api.topcoder-dev.com/v5/reviewSummations'
6+
WAIT_TIME: process.env.WAIT_TIME ? Number(process.env.WAIT_TIME) : 2000
97
}

mock-scorecard-api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ scoreSystems.forEach(element => {
1515
app.get('/scoreSystems', (req, res) => res.json(scoreSystems))
1616
app.get('/scorecards/:id', (req, res) => res.json(scorecardDetails))
1717

18-
app.listen(process.env.PORT || 4000);
18+
app.listen(process.env.PORT || 4000)
1919
console.log(`Server listening on http://localhost:${process.env.PORT || 4000}`)

0 commit comments

Comments
 (0)