Skip to content

Commit c36593b

Browse files
committed
test(server): added posibility to test on prefix
1 parent 4fda495 commit c36593b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/server/server.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var lastUserAgent = '';
99
var chunked = false;
1010
var delay = 0;
1111
var permanentError = 0;
12+
const prefix = '';
1213

1314
app.use (function(req, res, next) {
1415
var data='';
@@ -22,32 +23,32 @@ app.use (function(req, res, next) {
2223
next();
2324
});
2425
});
25-
app.get('/test/user-agent', (req,res) => {
26+
app.get(prefix + '/test/user-agent', (req,res) => {
2627
res.status(200).send(lastUserAgent);
2728
})
28-
app.get('/ready', (req,res) => {
29+
app.get(prefix + '/ready', (req,res) => {
2930
lastUserAgent = req.get('User-Agent');
3031
res.status(200).send("<html><body><h1>OK</h1></body></html>");
3132
})
32-
app.get('/health', (req,res) => {
33+
app.get(prefix + '/health', (req,res) => {
3334
lastUserAgent = req.get('User-Agent');
3435
res.status(200).send("<html><body><h1>OK</h1></body></html>");
3536
})
3637

37-
app.get('/ping', (req,res) => {
38+
app.get(prefix + '/ping', (req,res) => {
3839
lastUserAgent = req.get('User-Agent');
3940
if(req.query['verbose'] == 'true') {
4041
res.status(200).send("<html><body><h1>OK</h1></body></html>");
4142
} else {
4243
res.status(204).end();
4344
}
4445
})
45-
app.post('/log', (req,res) => {
46+
app.post(prefix + '/log', (req,res) => {
4647
console.log(req.body);
4748
res.status(204).end();
4849
})
4950

50-
app.post('/api/v2/write', (req,res) => {
51+
app.post(prefix + '/api/v2/write', (req,res) => {
5152
chunked = false;
5253
if(checkWriteParams(req, res) && handleAuthentication(req, res)) {
5354
//console.log('Write');
@@ -132,7 +133,7 @@ app.post('/api/v2/write', (req,res) => {
132133
}
133134
})
134135

135-
app.post('/write', (req,res) => {
136+
app.post(prefix + '/write', (req,res) => {
136137
if(checkWriteParamsV1(req, res) ) {
137138
var points = parsePoints(req.body);
138139
if(Array.isArray(points) && points.length > 0) {
@@ -170,7 +171,7 @@ app.post('/write', (req,res) => {
170171
}
171172
})
172173

173-
app.post('/api/v2/delete', (req,res) => {
174+
app.post(prefix + '/api/v2/delete', (req,res) => {
174175
console.log('Deleteting points');
175176
pointsdb = [];
176177
res.status(204).end();
@@ -259,7 +260,7 @@ function sleep(milliseconds) {
259260
} while (currentDate - date < milliseconds);
260261
}
261262

262-
app.post('/api/v2/query', (req,res) => {
263+
app.post(prefix+'/api/v2/query', (req,res) => {
263264
//console.log("Query with: " + req.body);
264265
if(checkQueryParams(req, res) && handleAuthentication(req, res)) {
265266
var queryObj = JSON.parse(req.body);

0 commit comments

Comments
 (0)