0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00

move logger setup to index.js + tests

This commit is contained in:
Alex Kocharin 2014-12-22 20:58:25 +03:00
parent fc3668885d
commit fad4f457ae
3 changed files with 56 additions and 2 deletions

View file

@ -75,8 +75,6 @@ function afterConfigLoad() {
if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version
if (!config.self_path) config.self_path = Path.resolve(config_path)
logger.setup(config.logs)
var hostport = get_hostport()
server(config)
.listen(hostport[1], hostport[0])

View file

@ -10,6 +10,8 @@ var Cats = require('./status-cats')
var Storage = require('./storage')
module.exports = function(config_hash) {
Logger.setup(config_hash.logs)
var config = Config(config_hash)
var storage = Storage(config)
var auth = Auth(config)

54
test/unit/toplevel.js Normal file
View file

@ -0,0 +1,54 @@
var assert = require('assert')
var express = require('express')
var request = require('request')
var rimraf = require('rimraf')
var sinopia = require('../../')
var config = {
storage: './test-storage',
packages: {
'*': {
allow_access: '$all',
},
},
logs: [
{type: 'stdout', format: 'pretty', level: 'fatal'}
],
}
describe('toplevel', function() {
var port
before(function(done) {
rimraf(__dirname + '/test-storage', done)
})
before(function(done) {
var app = express()
app.use(sinopia(config))
var server = require('http').createServer(app)
server.listen(0, function() {
port = server.address().port
done()
})
})
it('should respond on /', function(done) {
request({
url: 'http://localhost:' + port + '/',
}, function(err, res, body) {
assert(body.match(/<title>Sinopia<\/title>/))
done()
})
})
it('should respond on /whatever', function(done) {
request({
url: 'http://localhost:' + port + '/whatever',
}, function(err, res, body) {
assert(body.match(/no such package available/))
done()
})
})
})