2017-12-02 05:19:08 -05:00
|
|
|
import assert from 'assert';
|
|
|
|
import {readFile} from '../lib/test.utils';
|
2017-08-06 14:54:15 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
const getBinary = () => readFile('../fixtures/binary');
|
2017-08-06 14:54:15 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
export default function (server, server2) {
|
2017-08-06 14:54:15 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('testing anti-loop', () => {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server2.getPackage('testloop')
|
|
|
|
.status(404)
|
|
|
|
.body_error(/no such package/);
|
|
|
|
})
|
|
|
|
|
|
|
|
;['fwd'].forEach(function (pkg) {
|
|
|
|
let prefix = pkg + ': ';
|
|
|
|
pkg = 'test' + pkg;
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe(pkg, () => {
|
|
|
|
beforeAll(function () {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.putPackage(pkg, require('../fixtures/package')(pkg))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/created new package/);
|
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test(prefix + 'creating new package', () => {});
|
2017-08-06 14:54:15 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe(pkg, () => {
|
|
|
|
beforeAll(function () {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.putVersion(pkg, '0.1.1', require('../fixtures/package')(pkg))
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/published/);
|
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test(prefix + 'uploading new package version', () => {});
|
2017-08-06 14:54:15 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test(prefix + 'uploading incomplete tarball', () => {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.putTarballIncomplete(pkg, pkg + '.bad', getBinary(), 3000);
|
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('tarball', () => {
|
|
|
|
beforeAll(function () {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.putTarball(pkg, pkg + '.file', getBinary())
|
|
|
|
.status(201)
|
|
|
|
.body_ok(/.*/);
|
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test(prefix + 'uploading new tarball', () => {
|
2017-08-06 14:54:15 -05:00
|
|
|
});
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test(prefix + 'downloading tarball from server1', () => {
|
2017-08-06 14:54:15 -05:00
|
|
|
return server.getTarball(pkg, pkg + '.file')
|
|
|
|
.status(200)
|
|
|
|
.then(function (body) {
|
|
|
|
assert.deepEqual(body, getBinary());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-02 05:20:27 -05:00
|
|
|
}
|