2013-09-27 07:36:10 -05:00
|
|
|
var rimraf = require('rimraf');
|
|
|
|
var fork = require('child_process').fork;
|
|
|
|
var assert = require('assert');
|
|
|
|
var readfile = require('fs').readFileSync;
|
|
|
|
var ex = module.exports;
|
|
|
|
var server = process.server;
|
|
|
|
var server2 = process.server2;
|
|
|
|
var forks = process.forks;
|
|
|
|
|
|
|
|
ex['starting servers'] = function(cb) {
|
|
|
|
var count = 0;
|
|
|
|
function start(dir, conf) {
|
|
|
|
count++;
|
|
|
|
rimraf(dir, function() {
|
2013-09-28 06:08:38 -05:00
|
|
|
var f = fork('../bin/sinopia', ['-c', conf], {silent: true});
|
2013-09-27 07:36:10 -05:00
|
|
|
forks.push(f);
|
|
|
|
f.on('message', function(msg) {
|
|
|
|
if ('sinopia_started' in msg) {
|
|
|
|
if (!--count) cb();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
start('./test-storage', './config-1.yaml', cb);
|
|
|
|
start('./test-storage2', './config-2.yaml', cb);
|
|
|
|
};
|
|
|
|
|
|
|
|
ex['authentication to servers'] = function(cb) {
|
|
|
|
var count = 0;
|
|
|
|
[server, server2].forEach(function(server) {
|
|
|
|
count++;
|
|
|
|
server.auth('test', 'test', function(res, body) {
|
2013-09-28 06:14:51 -05:00
|
|
|
assert.equal(res.statusCode, 201);
|
2013-09-27 07:36:10 -05:00
|
|
|
assert.notEqual(body.ok.indexOf('"test"'), -1);
|
|
|
|
if (!--count) cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|