0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

style fix

This commit is contained in:
Alex Kocharin 2013-12-13 18:00:46 +04:00
parent 8149f883b0
commit ee16b06b3a
4 changed files with 150 additions and 150 deletions

View file

@ -8,113 +8,113 @@ var assert = require('assert')
ex['trying to fetch non-existent package'] = function(cb) { ex['trying to fetch non-existent package'] = function(cb) {
server.get_package('testpkg', function(res, body) { server.get_package('testpkg', function(res, body) {
// shouldn't exist yet // shouldn't exist yet
assert.equal(res.statusCode, 404); assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package')); assert(~body.error.indexOf('no such package'))
cb(); cb()
}); })
}; }
ex['creating new package'] = function(cb) { ex['creating new package'] = function(cb) {
server.put_package('testpkg', require('./lib/package')('testpkg'), function(res, body) { server.put_package('testpkg', require('./lib/package')('testpkg'), function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('created new package')); assert(~body.ok.indexOf('created new package'))
cb(); cb()
}); })
}; }
ex['downloading non-existent tarball'] = function(cb) { ex['downloading non-existent tarball'] = function(cb) {
server.get_tarball('testpkg', 'blahblah', function(res, body) { server.get_tarball('testpkg', 'blahblah', function(res, body) {
assert.equal(res.statusCode, 404); assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such file')); assert(~body.error.indexOf('no such file'))
cb(); cb()
}); })
}; }
ex['uploading incomplete tarball'] = function(cb) { ex['uploading incomplete tarball'] = function(cb) {
server.put_tarball_incomplete('testpkg', 'blahblah1', readfile('fixtures/binary'), 3000, function(res, body) { server.put_tarball_incomplete('testpkg', 'blahblah1', readfile('fixtures/binary'), 3000, function(res, body) {
cb(); cb()
}); })
}; }
ex['uploading new tarball'] = function(cb) { ex['uploading new tarball'] = function(cb) {
server.put_tarball('testpkg', 'blahblah', readfile('fixtures/binary'), function(res, body) { server.put_tarball('testpkg', 'blahblah', readfile('fixtures/binary'), function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(body.ok); assert(body.ok)
cb(); cb()
}); })
}; }
ex['doubleerr test'] = function(cb) { ex['doubleerr test'] = function(cb) {
server.put_tarball('testfwd2', 'blahblah', readfile('fixtures/binary'), function(res, body) { server.put_tarball('testfwd2', 'blahblah', readfile('fixtures/binary'), function(res, body) {
assert.equal(res.statusCode, 404); assert.equal(res.statusCode, 404)
assert(body.error); assert(body.error)
cb(); cb()
}); })
}; }
ex['downloading newly created tarball'] = function(cb) { ex['downloading newly created tarball'] = function(cb) {
server.get_tarball('testpkg', 'blahblah', function(res, body) { server.get_tarball('testpkg', 'blahblah', function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8')); assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
cb(); cb()
}); })
}; }
ex['uploading new package version for bad pkg'] = function(cb) { ex['uploading new package version for bad pkg'] = function(cb) {
server.put_version('testpxg', '0.0.1', require('./lib/package')('testpxg'), function(res, body) { server.put_version('testpxg', '0.0.1', require('./lib/package')('testpxg'), function(res, body) {
assert.equal(res.statusCode, 404); assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package')); assert(~body.error.indexOf('no such package'))
cb(); cb()
}); })
}; }
ex['uploading new package version (bad sha)'] = function(cb) { ex['uploading new package version (bad sha)'] = function(cb) {
var pkg = require('./lib/package')('testpkg') var pkg = require('./lib/package')('testpkg')
pkg.dist.shasum = crypto.createHash('sha1').update('fake').digest('hex') pkg.dist.shasum = crypto.createHash('sha1').update('fake').digest('hex')
server.put_version('testpkg', '0.0.1', pkg, function(res, body) { server.put_version('testpkg', '0.0.1', pkg, function(res, body) {
assert.equal(res.statusCode, 400); assert.equal(res.statusCode, 400)
assert(~body.error.indexOf('shasum error')); assert(~body.error.indexOf('shasum error'))
cb(); cb()
}); })
}; }
ex['uploading new package version'] = function(cb) { ex['uploading new package version'] = function(cb) {
var pkg = require('./lib/package')('testpkg') var pkg = require('./lib/package')('testpkg')
pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex') pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex')
server.put_version('testpkg', '0.0.1', pkg, function(res, body) { server.put_version('testpkg', '0.0.1', pkg, function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('published')); assert(~body.ok.indexOf('published'))
cb(); cb()
}); })
}; }
ex['downloading newly created package'] = function(cb) { ex['downloading newly created package'] = function(cb) {
server.get_package('testpkg', function(res, body) { server.get_package('testpkg', function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.equal(body.name, 'testpkg'); assert.equal(body.name, 'testpkg')
assert.equal(body.versions['0.0.1'].name, 'testpkg'); assert.equal(body.versions['0.0.1'].name, 'testpkg')
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55551/testpkg/-/blahblah'); assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55551/testpkg/-/blahblah')
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'}); assert.deepEqual(body['dist-tags'], {latest: '0.0.1'})
cb(); cb()
}); })
}; }
ex['downloading package via server2'] = function(cb) { ex['downloading package via server2'] = function(cb) {
server2.get_package('testpkg', function(res, body) { server2.get_package('testpkg', function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.equal(body.name, 'testpkg'); assert.equal(body.name, 'testpkg')
assert.equal(body.versions['0.0.1'].name, 'testpkg'); assert.equal(body.versions['0.0.1'].name, 'testpkg')
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah'); assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah')
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'}); assert.deepEqual(body['dist-tags'], {latest: '0.0.1'})
cb(); cb()
}); })
}; }
ex['publishing package / bad ro uplink'] = function(cb) { ex['publishing package / bad ro uplink'] = function(cb) {
server.put_package('baduplink', require('./lib/package')('baduplink'), function(res, body) { server.put_package('baduplink', require('./lib/package')('baduplink'), function(res, body) {
assert.equal(res.statusCode, 503); assert.equal(res.statusCode, 503)
assert(~body.error.indexOf('one of the uplinks is down, refuse to publish')); assert(~body.error.indexOf('one of the uplinks is down, refuse to publish'))
cb(); cb()
}); })
} }

View file

@ -1,13 +1,13 @@
var assert = require('assert'); var assert = require('assert')
var ex = module.exports; , ex = module.exports
ex['trying to fetch non-existent package'] = function(cb) { ex['trying to fetch non-existent package'] = function(cb) {
var f = fork('../bin/sinopia', ['-c', './config/log-1.yaml'], {silent: true}); var f = fork('../bin/sinopia', ['-c', './config/log-1.yaml'], {silent: true})
f.on('message', function(msg) { f.on('message', function(msg) {
if ('sinopia_started' in msg) { if ('sinopia_started' in msg) {
f.kill(); f.kill()
cb(); cb()
} }
}); })
}; }

View file

@ -1,75 +1,75 @@
var assert = require('assert'); var assert = require('assert')
var readfile = require('fs').readFileSync; , readfile = require('fs').readFileSync
var ex = module.exports; , ex = module.exports
var server = process.server; , server = process.server
var server2 = process.server2; , server2 = process.server2
ex['testing anti-loop'] = function(cb) { ex['testing anti-loop'] = function(cb) {
server2.get_package('testloop', function(res, body) { server2.get_package('testloop', function(res, body) {
assert.equal(res.statusCode, 404); assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package')); assert(~body.error.indexOf('no such package'))
cb(); cb()
}); })
}; }
['fwd', /*'loop'*/].forEach(function(pkg) { ['fwd', /*'loop'*/].forEach(function(pkg) {
var prefix = pkg+': '; var prefix = pkg + ': '
pkg = 'test'+pkg; pkg = 'test' + pkg
ex[prefix+'creating new package'] = function(cb) { ex[prefix+'creating new package'] = function(cb) {
server.put_package(pkg, require('./lib/package')(pkg), function(res, body) { server.put_package(pkg, require('./lib/package')(pkg), function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('created new package')); assert(~body.ok.indexOf('created new package'))
cb(); cb()
}); })
}; }
ex[prefix+'uploading new package version'] = function(cb) { ex[prefix+'uploading new package version'] = function(cb) {
server.put_version(pkg, '0.1.1', require('./lib/package')(pkg), function(res, body) { server.put_version(pkg, '0.1.1', require('./lib/package')(pkg), function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('published')); assert(~body.ok.indexOf('published'))
cb(); cb()
}); })
}; }
ex[prefix+'downloading package via server2'] = function(cb) { ex[prefix+'downloading package via server2'] = function(cb) {
server2.get_package(pkg, function(res, body) { server2.get_package(pkg, function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.equal(body.name, pkg); assert.equal(body.name, pkg)
assert.equal(body.versions['0.1.1'].name, pkg); assert.equal(body.versions['0.1.1'].name, pkg)
assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/'+pkg+'/-/blahblah'); assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/'+pkg+'/-/blahblah')
cb(); cb()
}); })
}; }
ex[prefix+'uploading incomplete tarball'] = function(cb) { ex[prefix+'uploading incomplete tarball'] = function(cb) {
server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000, function(res, body) { server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000, function(res, body) {
cb(); cb()
}); })
}; }
ex[prefix+'uploading new tarball'] = function(cb) { ex[prefix+'uploading new tarball'] = function(cb) {
server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'), function(res, body) { server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'), function(res, body) {
assert.equal(res.statusCode, 201); assert.equal(res.statusCode, 201)
assert(body.ok); assert(body.ok)
cb(); cb()
}); })
}; }
ex[prefix+'downloading tarball from server1'] = function(cb) { ex[prefix+'downloading tarball from server1'] = function(cb) {
server.get_tarball(pkg, pkg+'.file', function(res, body) { server.get_tarball(pkg, pkg+'.file', function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8')); assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
cb(); cb()
}); })
}; }
ex[prefix+'downloading tarball from server2'] = function(cb) { ex[prefix+'downloading tarball from server2'] = function(cb) {
server2.get_tarball(pkg, pkg+'.file', function(res, body) { server2.get_tarball(pkg, pkg+'.file', function(res, body) {
assert.equal(res.statusCode, 200); assert.equal(res.statusCode, 200)
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8')); assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
cb(); cb()
}); })
}; }
}); })

View file

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