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
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it('testing anti-loop', function () {
|
|
|
|
return server2.get_package('testloop')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/no such package/)
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
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() {
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function () {
|
|
|
|
return server.put_package(pkg, require('./lib/package')(pkg))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/created new package/)
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
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() {
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function () {
|
|
|
|
return server.put_version(pkg, '0.1.1', require('./lib/package')(pkg))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/published/)
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
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
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it(prefix+'uploading incomplete tarball', function () {
|
|
|
|
return server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000)
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
describe('tarball', function() {
|
2015-04-11 12:11:04 -05:00
|
|
|
before(function () {
|
|
|
|
return server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/.*/)
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
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
|
|
|
|
2015-04-11 12:11:04 -05:00
|
|
|
it(prefix+'downloading tarball from server1', function () {
|
|
|
|
return server.get_tarball(pkg, pkg+'.file')
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
2016-07-30 14:02:50 -05:00
|
|
|
assert.deepEqual(body, readfile('fixtures/binary'))
|
2015-04-11 12:11:04 -05:00
|
|
|
})
|
2014-11-12 06:14:37 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 10:11:54 -05:00
|
|
|
}
|
|
|
|
|