2017-12-02 05:19:08 -05:00
|
|
|
import assert from 'assert';
|
|
|
|
import crypto from 'crypto';
|
2013-12-19 10:11:54 -05:00
|
|
|
|
|
|
|
function readfile(x) {
|
2017-04-19 14:15:28 -05:00
|
|
|
return require('fs').readFileSync(__dirname + '/' + x);
|
2013-12-19 10:11:54 -05:00
|
|
|
}
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
export default function (server, server2) {
|
2013-12-29 01:40:47 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('downloading non-existent tarball #1 / srv2', () => {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server2.getTarball('testpkg-gh29', 'blahblah')
|
2015-04-11 12:11:04 -05:00
|
|
|
.status(404)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_error(/no such package/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('pkg-gh29', () => {
|
|
|
|
beforeAll(function() {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.putPackage('testpkg-gh29', require('./fixtures/package')('testpkg-gh29'))
|
2015-04-11 12:11:04 -05:00
|
|
|
.status(201)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/created new package/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('creating new package / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('downloading non-existent tarball #2 / srv2', () => {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server2.getTarball('testpkg-gh29', 'blahblah')
|
2015-04-11 12:11:04 -05:00
|
|
|
.status(404)
|
2018-01-27 20:40:07 -05:00
|
|
|
.body_error(/no such file available/);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('tarball', () => {
|
|
|
|
beforeAll(function() {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.putTarball('testpkg-gh29', 'blahblah', readfile('fixtures/binary'))
|
2015-04-11 12:11:04 -05:00
|
|
|
.status(201)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/.*/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('uploading new tarball / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('pkg version', () => {
|
|
|
|
beforeAll(function() {
|
2017-08-06 14:54:15 -05:00
|
|
|
const pkg = require('./fixtures/package')('testpkg-gh29');
|
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex');
|
2017-06-28 15:56:02 -05:00
|
|
|
return server.putVersion('testpkg-gh29', '0.0.1', pkg)
|
2015-04-11 12:11:04 -05:00
|
|
|
.status(201)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/published/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('uploading new package version / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('downloading newly created tarball / srv2', () => {
|
2017-06-28 15:56:02 -05:00
|
|
|
return server2.getTarball('testpkg-gh29', 'blahblah')
|
2018-01-27 20:40:07 -05:00
|
|
|
.status(200)
|
|
|
|
.then(function(body) {
|
|
|
|
assert.deepEqual(body, readfile('fixtures/binary'));
|
|
|
|
});
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-02 05:19:08 -05:00
|
|
|
}
|