Skip to content

Commit 265f561

Browse files
authored
test/nginx: prefix test-specific server endpoints (#2046)
Help reason about routing by clearly delineating test-specific paths from those which are shadowing real paths.
1 parent e02a051 commit 265f561

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

test/nginx/mock-http-server/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ app.use('/-/', (req, res, next) => {
2525
next();
2626
});
2727

28-
app.get('/health', (req, res) => res.send('OK'));
29-
app.get('/request-log', (req, res) => res.json(requests));
30-
app.get('/reset', (req, res) => {
28+
app.get('/__mock_http_server/health', (req, res) => res.send('OK'));
29+
app.get('/__mock_http_server/request-log', (req, res) => res.json(requests));
30+
app.get('/__mock_http_server/reset', (req, res) => {
3131
requests.length = 0;
3232
res.json('OK');
3333
});

test/nginx/mock-sentry/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ app.use(express.json({
2727
'application/reports+json', // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/report-to#violation_report_syntax
2828
],
2929
}));
30-
app.get('/event-log', (req, res) => res.json(events));
31-
app.get('/reset', (req, res) => {
30+
app.get('/__mock_sentry/event-log', (req, res) => res.json(events));
31+
app.get('/__mock_sentry/reset', (req, res) => {
3232
events.length = 0;
3333
res.json('OK');
3434
});

test/nginx/setup-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ log "Starting test services..."
3131
docker_compose up --build --detach
3232

3333
log "Waiting for mock backend..."
34-
wait_for_http_response 5 localhost:8383/health 200
34+
wait_for_http_response 5 localhost:8383/__mock_http_server/health 200
3535
log "Waiting for mock enketo..."
36-
wait_for_http_response 5 localhost:8005/health 200
36+
wait_for_http_response 5 localhost:8005/__mock_http_server/health 200
3737
log "Waiting for nginx..."
3838
wait_for_http_response 5 localhost:9000 421
3939

test/nginx/src/lib.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
};
1414

1515
async function assertSentryReceived(...expectedRequests) {
16-
const { status, body } = await requestSentryMock({ path:'/event-log' });
16+
const { status, body } = await requestSentryMock({ path:'/__mock_sentry/event-log' });
1717
assert.equal(status, 200);
1818

1919
const actual = JSON.parse(body);
@@ -27,7 +27,7 @@ async function assertSentryReceived(...expectedRequests) {
2727
}
2828

2929
async function resetSentryMock() {
30-
const res = await requestSentryMock({ path:'/reset' });
30+
const res = await requestSentryMock({ path:'/__mock_sentry/reset' });
3131
assert.equal(res.status, 200);
3232
}
3333

test/nginx/src/mocha/nginx.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ function assertBackendReceived(...expectedRequests) {
11621162
}
11631163

11641164
async function assertMockHttpReceived(port, expectedRequests) {
1165-
const res = await request(`http://localhost:${port}/request-log`);
1165+
const res = await request(`http://localhost:${port}/__mock_http_server/request-log`);
11661166
assert.isTrue(res.ok);
11671167
assert.deepEqual(expectedRequests, await res.json());
11681168
}
@@ -1176,7 +1176,7 @@ function resetBackendMock() {
11761176
}
11771177

11781178
async function resetMock(port) {
1179-
const res = await request(`http://localhost:${port}/reset`);
1179+
const res = await request(`http://localhost:${port}/__mock_http_server/reset`);
11801180
assert.isTrue(res.ok);
11811181
}
11821182

0 commit comments

Comments
 (0)