Skip to content

Commit bc4a429

Browse files
committed
Start reqlite server programmatically instead of using child.spawn()
1 parent 180eb7e commit bc4a429

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"db:start": "docker run -d -p 28015:28015 -p 8090:8080 -v $PWD/db:/data --name expertsdb rethinkdb",
99
"db:stop": "docker stop expertsdb",
1010
"db:rm": "docker rm expertsdb",
11-
"test": "eslint src/ && NODE_ENV=testing node test/index.js | tap-spec"
11+
"test": "eslint src/ && node test/index.js | tap-spec"
1212
},
1313
"keywords": [
1414
"rest",

server/test/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/* eslint global-require: 0 */
2-
// get spawn
3-
const spawn = require('child_process').spawn;
2+
// say we're testing to evade excessive logging
3+
// usage of process.env is workaround for issues with setting env vars in windows
4+
process.env.NODE_ENV = 'testing';
45
// require babel require hook
56
require('babel-core/register');
6-
// reqlite instance
7-
const reqlite = spawn('reqlite');
8-
// wait for start
9-
reqlite.stderr.on('data', () => {
10-
// require main tests
11-
const startTests = require('./main').default;
12-
startTests(reqlite);
13-
});
7+
// create reqlite instance
8+
const ReqliteServer = require('reqlite');
9+
const server = new ReqliteServer({silent: true});
10+
// require and start main tests
11+
const startTests = require('./main').default;
12+
startTests(server);

server/test/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default (reqlite) => {
3030
// close db connections
3131
test((t) => {
3232
setImmediate(() => r.getPoolMaster().drain());
33-
reqlite.kill();
33+
reqlite.stop();
3434
t.end();
3535
});
3636
});

0 commit comments

Comments
 (0)