diff options
author | John McLear <john@mclear.co.uk> | 2015-06-29 11:00:00 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-06-29 11:00:00 +0100 |
commit | d803ac128ecae61402d98bdf14f547c5fd52a1c4 (patch) | |
tree | 93ebe40b6d8295a6a81c216932b726314246e2fa /tests | |
parent | e48d605d2d3c825039778a5fab5980a170df7610 (diff) | |
download | etherpad-lite-d803ac128ecae61402d98bdf14f547c5fd52a1c4.zip |
use settings for backend tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/backend/loadSettings.js | 17 | ||||
-rw-r--r-- | tests/backend/specs/api/chat.js | 3 | ||||
-rw-r--r-- | tests/backend/specs/api/pad.js | 3 | ||||
-rw-r--r-- | tests/backend/specs/api/sessionsAndGroups.js | 3 |
4 files changed, 23 insertions, 3 deletions
diff --git a/tests/backend/loadSettings.js b/tests/backend/loadSettings.js new file mode 100644 index 00000000..f208fe3d --- /dev/null +++ b/tests/backend/loadSettings.js @@ -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; diff --git a/tests/backend/specs/api/chat.js b/tests/backend/specs/api/chat.js index 59b7edc0..2bcd9783 100644 --- a/tests/backend/specs/api/chat.js +++ b/tests/backend/specs/api/chat.js @@ -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'); diff --git a/tests/backend/specs/api/pad.js b/tests/backend/specs/api/pad.js index cbfcfe30..1b6e883a 100644 --- a/tests/backend/specs/api/pad.js +++ b/tests/backend/specs/api/pad.js @@ -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'); diff --git a/tests/backend/specs/api/sessionsAndGroups.js b/tests/backend/specs/api/sessionsAndGroups.js index 4742852f..4089656a 100644 --- a/tests/backend/specs/api/sessionsAndGroups.js +++ b/tests/backend/specs/api/sessionsAndGroups.js @@ -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'); |