0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00
verdaccio/test/startup.js

43 lines
997 B
JavaScript
Raw Normal View History

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