1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/functional/sanity/mirror.ts

80 lines
2.5 KiB
TypeScript
Raw Normal View History

2017-12-02 11:19:08 +01:00
import {readFile} from '../lib/test.utils';
2018-06-24 10:11:52 +02:00
import {API_MESSAGE, HTTP_STATUS} from "../../../src/lib/constants";
2018-06-23 01:03:25 +02:00
import generatePkg from '../fixtures/package';
2018-06-24 10:11:52 +02:00
import {TARBALL} from '../config.functional';
2017-12-02 11:19:08 +01:00
const getBinary = () => readFile('../fixtures/binary');
2017-12-02 11:19:08 +01:00
export default function (server, server2) {
2018-06-23 01:03:25 +02: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-23 01:03:25 +02:00
describe('mirror', () => {
const pkgList = ['pkg1', 'pkg2', 'pkg3'];
2018-06-23 01:03:25 +02:00
pkgList.forEach(function (pkg) {
let prefix = pkg;
2018-06-24 10:11:52 +02:00
pkg = `test-mirror-${pkg}`;
2018-06-23 01:03:25 +02:00
describe(`testing mirror for ${pkg}`, () => {
2017-12-02 11:19:08 +01:00
beforeAll(function () {
2018-06-23 01:03:25 +02:00
return server2.putPackage(pkg, generatePkg(pkg))
.status(HTTP_STATUS.CREATED)
2018-06-24 10:11:52 +02:00
.body_ok(API_MESSAGE.PKG_CREATED);
});
2018-06-23 01:03:25 +02:00
test(prefix + 'creating new package', () => {});
2018-12-16 21:30:49 +01:00
describe(`${pkg}`, () => {
2017-12-02 11:19:08 +01:00
beforeAll(function () {
2018-06-23 01:03:25 +02:00
return server2.putVersion(pkg, '0.1.1', generatePkg(pkg))
.status(HTTP_STATUS.CREATED)
.body_ok(/published/);
});
2018-06-23 01:03:25 +02:00
test(`should ${prefix} uploading new package version`, () => {});
test(`${prefix} uploading incomplete tarball`, () => {
return server2.putTarballIncomplete(pkg, pkg + '.bad', getBinary(), 3000);
});
2018-06-23 01:03:25 +02:00
describe('should put a tarball', () => {
beforeAll(function () {
2018-06-23 08:35:06 +02:00
return server2.putTarball(pkg, TARBALL, getBinary())
2018-06-23 01:03:25 +02:00
.status(HTTP_STATUS.CREATED)
.body_ok(/.*/);
});
test(`should ${prefix} uploading new tarball`, () => {});
test(`should ${prefix} downloading tarball from server2`, () => {
2018-06-23 08:35:06 +02:00
return server2.getTarball(pkg, TARBALL)
2018-06-23 01:03:25 +02: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 08:35:06 +02:00
return server.getTarball(pkg, TARBALL)
2018-06-23 01:03:25 +02:00
.status(HTTP_STATUS.OK)
.then(function (body) {
expect(body).toEqual(getBinary());
});
});
});
});
});
});
});
2017-12-02 11:20:27 +01:00
}