use settings for backend tests
This commit is contained in:
parent
e48d605d2d
commit
d803ac128e
4 changed files with 23 additions and 3 deletions
17
tests/backend/loadSettings.js
Normal file
17
tests/backend/loadSettings.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
var jsonminify = require(__dirname+"/../../src/node_modules/jsonminify");
|
||||
|
||||
function loadSettings(){
|
||||
var settingsStr = fs.readFileSync(__dirname+"/../../settings.json").toString();
|
||||
// try to parse the settings
|
||||
var settings;
|
||||
try {
|
||||
if(settingsStr) {
|
||||
settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
|
||||
return JSON.parse(settingsStr);
|
||||
}
|
||||
}catch(e){
|
||||
console.error("whoops something is bad with settings");
|
||||
}
|
||||
}
|
||||
|
||||
exports.loadSettings = loadSettings;
|
|
@ -1,7 +1,8 @@
|
|||
var assert = require('assert')
|
||||
supertest = require(__dirname+'/../../../../src/node_modules/supertest'),
|
||||
fs = require('fs'),
|
||||
api = supertest('http://localhost:9001');
|
||||
settings = require(__dirname+'/../../loadSettings').loadSettings(),
|
||||
api = supertest('http://'+settings.ip+":"+settings.port),
|
||||
path = require('path');
|
||||
|
||||
var filePath = path.join(__dirname, '../../../../APIKEY.txt');
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var assert = require('assert')
|
||||
supertest = require(__dirname+'/../../../../src/node_modules/supertest'),
|
||||
fs = require('fs'),
|
||||
api = supertest('http://localhost:9001');
|
||||
settings = require(__dirname+'/../../loadSettings').loadSettings(),
|
||||
api = supertest('http://'+settings.ip+":"+settings.port),
|
||||
path = require('path'),
|
||||
async = require(__dirname+'/../../../../src/node_modules/async');
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var assert = require('assert')
|
||||
supertest = require(__dirname+'/../../../../src/node_modules/supertest'),
|
||||
fs = require('fs'),
|
||||
api = supertest('http://localhost:9001');
|
||||
settings = require(__dirname+'/../../loadSettings').loadSettings(),
|
||||
api = supertest('http://'+settings.ip+":"+settings.port),
|
||||
path = require('path');
|
||||
|
||||
var filePath = path.join(__dirname, '../../../../APIKEY.txt');
|
||||
|
|
Loading…
Reference in a new issue