2013-12-19 16:11:54 +01:00
|
|
|
var assert = require('assert')
|
2014-11-12 12:14:37 +01:00
|
|
|
var crypto = require('crypto')
|
2013-12-19 16:11:54 +01:00
|
|
|
|
|
|
|
function readfile(x) {
|
2014-11-12 12:14:37 +01:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x)
|
2013-12-19 16:11:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function() {
|
2014-11-12 12:14:37 +01:00
|
|
|
var server = process.server
|
|
|
|
var server2 = process.server2
|
2013-12-29 07:40:47 +01:00
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('downloading non-existent tarball #1 / srv2', function () {
|
|
|
|
return server2.get_tarball('testpkg-gh29', 'blahblah')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/no such package/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('pkg-gh29', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
before(function () {
|
|
|
|
return server.put_package('testpkg-gh29', require('./lib/package')('testpkg-gh29'))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/created new package/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('creating new package / srv1', function(){})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('downloading non-existent tarball #2 / srv2', function () {
|
|
|
|
return server2.get_tarball('testpkg-gh29', 'blahblah')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/no such file/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('tarball', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
before(function () {
|
|
|
|
return server.put_tarball('testpkg-gh29', 'blahblah', readfile('fixtures/binary'))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/.*/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('uploading new tarball / srv1', function(){})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('pkg version', function() {
|
2015-04-11 19:11:04 +02:00
|
|
|
before(function () {
|
2014-11-12 12:14:37 +01:00
|
|
|
var pkg = require('./lib/package')('testpkg-gh29')
|
|
|
|
pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex')
|
2015-04-11 19:11:04 +02:00
|
|
|
return server.put_version('testpkg-gh29', '0.0.1', pkg)
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/published/)
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
it('uploading new package version / srv1', function(){})
|
2013-12-19 16:11:54 +01:00
|
|
|
|
2015-04-11 19:11:04 +02:00
|
|
|
it('downloading newly created tarball / srv2', function () {
|
|
|
|
return server2.get_tarball('testpkg-gh29', 'blahblah')
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
2016-07-30 21:02:50 +02:00
|
|
|
assert.deepEqual(body, readfile('fixtures/binary'))
|
2015-04-11 19:11:04 +02:00
|
|
|
})
|
2014-11-12 12:14:37 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2013-12-19 16:11:54 +01:00
|
|
|
}
|
|
|
|
|