0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/functional/sanity/mirror.js

80 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-12-02 05:19:08 -05:00
import {readFile} from '../lib/test.utils';
2018-06-22 18:03:25 -05:00
import {HTTP_STATUS} from "../../../src/lib/constants";
import generatePkg from '../fixtures/package';
2018-06-23 01:35:06 -05:00
import {TARBALL} from '../config.func';
2017-12-02 05:19:08 -05:00
const getBinary = () => readFile('../fixtures/binary');
2017-12-02 05:19:08 -05:00
export default function (server, server2) {
2018-06-22 18:03:25 -05:00
describe('anti-loop testing', () => {
test('testing anti-loop', () => {
return server2.getPackage('testloop').status(HTTP_STATUS.NOT_FOUND)
.body_error(/no such package/);
});
});
2018-06-22 18:03:25 -05:00
describe('mirror', () => {
const pkgList = ['pkg1', 'pkg2', 'pkg3'];
2018-06-22 18:03:25 -05:00
pkgList.forEach(function (pkg) {
let prefix = pkg;
pkg = 'test-mirror-' + pkg;
describe(`testing mirror for ${pkg}`, () => {
2017-12-02 05:19:08 -05:00
beforeAll(function () {
2018-06-22 18:03:25 -05:00
return server2.putPackage(pkg, generatePkg(pkg))
.status(HTTP_STATUS.CREATED)
.body_ok(/created new package/);
});
2018-06-22 18:03:25 -05:00
test(prefix + 'creating new package', () => {});
2018-06-22 18:03:25 -05:00
describe(pkg, () => {
2017-12-02 05:19:08 -05:00
beforeAll(function () {
2018-06-22 18:03:25 -05:00
return server2.putVersion(pkg, '0.1.1', generatePkg(pkg))
.status(HTTP_STATUS.CREATED)
.body_ok(/published/);
});
2018-06-22 18:03:25 -05:00
test(`should ${prefix} uploading new package version`, () => {});
test(`${prefix} uploading incomplete tarball`, () => {
return server2.putTarballIncomplete(pkg, pkg + '.bad', getBinary(), 3000);
});
2018-06-22 18:03:25 -05:00
describe('should put a tarball', () => {
beforeAll(function () {
2018-06-23 01:35:06 -05:00
return server2.putTarball(pkg, TARBALL, getBinary())
2018-06-22 18:03:25 -05:00
.status(HTTP_STATUS.CREATED)
.body_ok(/.*/);
});
test(`should ${prefix} uploading new tarball`, () => {});
test(`should ${prefix} downloading tarball from server2`, () => {
2018-06-23 01:35:06 -05:00
return server2.getTarball(pkg, TARBALL)
2018-06-22 18:03:25 -05:00
.status(HTTP_STATUS.OK)
.then(function (body) {
expect(body).toEqual(getBinary());
});
});
test('testing mirror server1', () => {
return server.getPackage(pkg).status(HTTP_STATUS.OK);
});
test(`should ${prefix} downloading tarball from server1`, () => {
2018-06-23 01:35:06 -05:00
return server.getTarball(pkg, TARBALL)
2018-06-22 18:03:25 -05:00
.status(HTTP_STATUS.OK)
.then(function (body) {
expect(body).toEqual(getBinary());
});
});
});
});
});
});
});
2017-12-02 05:20:27 -05:00
}