1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00
verdaccio/test/functional/index.js
Alex Kocharin 6a778e8c17 change code style to jshttp
close #155, see reasons there

This is a huge commit, so let me know if it will cause
any trouble, I might consider reverting it if it's the case.
2014-11-12 17:37:43 +03:00

80 lines
2.1 KiB
JavaScript

require('./lib/startup')
var assert = require('assert')
var async = require('async')
var exec = require('child_process').exec
var crypto = require('crypto')
function readfile(x) {
return require('fs').readFileSync(__dirname + '/' + x)
}
describe('Func', function() {
var server = process.server
var server2 = process.server2
before(function(cb) {
async.parallel([
function(cb) {
require('./lib/startup').start('./test-storage', './config-1.yaml', cb)
},
function(cb) {
require('./lib/startup').start('./test-storage2', './config-2.yaml', cb)
},
], cb)
})
before(function(cb) {
async.map([server, server2], function(server, cb) {
server.debug(function(res, body) {
server.pid = body.pid
exec('lsof -p ' + Number(server.pid), function(err, result) {
server.fdlist = result
cb()
})
})
}, cb)
})
before(function auth(cb) {
async.map([server, server2], function(server, cb) {
server.auth('test', 'test', function(res, body) {
assert.equal(res.statusCode, 201)
assert.notEqual(body.ok.indexOf('"test"'), -1)
cb()
})
}, cb)
})
it('authenticate', function(){/* test for before() */})
require('./basic')()
require('./gh29')()
require('./tags')()
require('./gzip')()
require('./incomplete')()
require('./mirror')()
require('./newnpmreg')()
require('./nullstorage')()
require('./race')()
require('./racycrash')()
require('./security')()
require('./adduser')()
require('./addtag')()
after(function(cb) {
async.map([server, server2], function(server, cb) {
exec('lsof -p ' + Number(server.pid), function(err, result) {
assert.equal(server.fdlist, result.split('\n').filter(function(q) {
if (q.match(/TCP .*->.* \(ESTABLISHED\)/)) return false
if (q.match(/\/libcrypt-[^\/]+\.so/)) return false
if (q.match(/\/node_modules\/crypt3\/build\/Release/)) return false
return true
}).join('\n'))
cb()
})
}, cb)
})
})