mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 03:07:47 +00:00
Update API tests, enforce all metrics are from the past
This commit is contained in:
@@ -600,7 +600,7 @@ request.set('User-Agent', 'PostgSail unit tests');
|
||||
for (i = 0; i < test.vessel_metrics['metrics'].length; i++) {
|
||||
data[i] = test.vessel_metrics['metrics'][i];
|
||||
// Override time, -2h to allow to new data later without delay.
|
||||
data[i]['time'] = moment.utc().subtract(2, 'hours').add(i, 'minutes').format();
|
||||
data[i]['time'] = moment.utc().subtract(1, 'day').add(i, 'minutes').format();
|
||||
// Override client_id
|
||||
data[i]['client_id'] = test.vessel_metadata.client_id;
|
||||
}
|
||||
@@ -611,6 +611,11 @@ request.set('User-Agent', 'PostgSail unit tests');
|
||||
// Force last valid entry to be back in time from previous, it should be ignore silently
|
||||
data.at(-1).time = moment.utc(data.at(-3).time).subtract(1, 'minutes').format();
|
||||
//console.log(data[0]);
|
||||
// Force the -2 entry to be in the future add 1 year, it should be ignore silently
|
||||
data.splice(i-2, 1, data.at(-2))
|
||||
data.at(-3).time = moment.utc(data.at(-3).time).add(1, 'year').format();
|
||||
//console.log(data.at(-2));
|
||||
//console.log(data.at(-1));
|
||||
|
||||
it('/metrics?select=time', function(done) {
|
||||
request = supertest.agent(test.cname);
|
||||
@@ -629,6 +634,7 @@ request.set('User-Agent', 'PostgSail unit tests');
|
||||
res.header['content-type'].should.match(new RegExp('json','g'));
|
||||
res.header['server'].should.match(new RegExp('postgrest','g'));
|
||||
should.exist(res.body);
|
||||
//console.log(res.body);
|
||||
res.body.length.should.match(test.vessel_metrics['metrics'].length-3);
|
||||
done(err);
|
||||
});
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* npm install supertest should mocha mochawesome moment
|
||||
* alias mocha="./node_modules/mocha/bin/_mocha"
|
||||
* mocha index.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
* mocha index2.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -432,11 +432,11 @@ request.set('User-Agent', 'PostgSail unit tests');
|
||||
for (i = 0; i < test.vessel_metrics['metrics'].length; i++) {
|
||||
data[i] = test.vessel_metrics['metrics'][i];
|
||||
// Override time, +1h because previous sample include 47 entry.
|
||||
data[i]['time'] = moment().add(1, 'hour').add(i, 'minutes').format();
|
||||
data[i]['time'] = moment.utc().subtract(2, 'hours').add(i, 'minutes').format();
|
||||
// Override client_id
|
||||
data[i]['client_id'] = test.vessel_metadata.client_id;
|
||||
}
|
||||
console.log(data[0]);
|
||||
//console.log(data[0]);
|
||||
|
||||
it('/metrics?select=time', function(done) {
|
||||
request = supertest.agent(test.cname);
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* npm install supertest should mocha mochawesome moment
|
||||
* alias mocha="./node_modules/mocha/bin/_mocha"
|
||||
* mocha index.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
* mocha index3.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
*
|
||||
*/
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
"use strict";
|
||||
/*
|
||||
* Unit test #5
|
||||
* Unit test #6
|
||||
* Public/Anonymous access
|
||||
*
|
||||
* process.env.PGSAIL_API_URI = from inside the docker
|
||||
*
|
||||
* npm install supertest should mocha mochawesome moment
|
||||
* alias mocha="./node_modules/mocha/bin/_mocha"
|
||||
* mocha index5.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
* mocha index6.js --reporter mochawesome --reporter-options reportDir=/mnt/postgsail/,reportFilename=report_api.html
|
||||
*
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user