2013-12-19 10:11:54 -05:00
|
|
|
var assert = require('assert')
|
|
|
|
|
|
|
|
function readfile(x) {
|
2014-11-12 06:14:37 -05:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x)
|
2013-12-19 10:11:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function() {
|
2014-11-12 06:14:37 -05:00
|
|
|
var server = process.server
|
|
|
|
var server2 = process.server2
|
2013-12-29 01:40:47 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it('testing anti-loop', function(cb) {
|
|
|
|
server2.get_package('testloop', function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 404)
|
|
|
|
assert(~body.error.indexOf('no such package'))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
;['fwd', /*'loop'*/].forEach(function(pkg) {
|
|
|
|
var prefix = pkg + ': '
|
|
|
|
pkg = 'test' + pkg
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
describe(pkg, function() {
|
|
|
|
before(function(cb) {
|
|
|
|
server.put_package(pkg, require('./lib/package')(pkg), function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 201)
|
|
|
|
assert(~body.ok.indexOf('created new package'))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it(prefix+'creating new package', function(){})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
describe(pkg, function() {
|
|
|
|
before(function(cb) {
|
|
|
|
server.put_version(pkg, '0.1.1', require('./lib/package')(pkg), function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 201)
|
|
|
|
assert(~body.ok.indexOf('published'))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it(prefix+'uploading new package version', function(){})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it(prefix+'uploading incomplete tarball', function(cb) {
|
|
|
|
server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000, function(res, body) {
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
describe('tarball', function() {
|
|
|
|
before(function(cb) {
|
|
|
|
server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'), function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 201)
|
|
|
|
assert(body.ok)
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it(prefix+'uploading new tarball', function(){})
|
2013-12-29 01:40:47 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it(prefix+'downloading tarball from server1', function(cb) {
|
|
|
|
server.get_tarball(pkg, pkg+'.file', function(res, body) {
|
|
|
|
assert.equal(res.statusCode, 200)
|
|
|
|
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
|
|
|
|
cb()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
}
|
|
|
|
|