0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/startup.js

40 lines
991 B
JavaScript
Raw Normal View History

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() {
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();
});
});
};