-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.test.js
48 lines (38 loc) · 1.15 KB
/
bootstrap.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
/*
Require this file inside tests
*/
require('./bootstrap');
var fs = require('fs');
if (!process.env.OVERRIDE) {
_.compact(fs.readFileSync('./ci/.env_test').toString('utf8').split('\n')).forEach(function (line) {
var pair = _.rest(line.split('export ')).join(' ').split('=').map(function trim(v) {
return v.trim();
});
process.env[pair[0]] = pair[1].replace(/"/g, '');
});
}
// ensure that we are running the tests in dev env
var ServerFactory = require('./server');
global.t = require('chai').assert;
global.request = require('supertest');
// Extend
t.isPrettyError = function (err, code, message) {
t.instanceOf(err, PrettyError);
t.ok(err instanceof PrettyError, err.toJSON());
t.strictEqual(err.code, code, 'pretty error ' + err.toString() + ' code should be code=' + code);
if (message) {
t.include(err.message, message);
}
};
/**
* @param {Function} f(app, config, logger, es, amqp)
*/
t.getAPP = function getAPP(f) {
ServerFactory(function (app, config, logger, es, amqp) {
// ensure that we are using test configuration
f(app, config, logger, es, amqp);
}, _.noop, {
amqpError: true
});
};