0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00
verdaccio/test/functional/sanity/mirror.ts

86 lines
2.6 KiB
TypeScript
Raw Normal View History

import { readFile } from '../lib/test.utils';
import { API_MESSAGE, HTTP_STATUS } from '../../../src/lib/constants';
import generatePkg from '../fixtures/package';
import { TARBALL } from '../config.functional';
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)
2018-06-22 18:03:25 -05:00
.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;
2018-06-24 03:11:52 -05:00
pkg = `test-mirror-${pkg}`;
2018-06-22 18:03:25 -05:00
describe(`testing mirror for ${pkg}`, () => {
2017-12-02 05:19:08 -05:00
beforeAll(function () {
return server2
.putPackage(pkg, generatePkg(pkg))
2018-06-22 18:03:25 -05:00
.status(HTTP_STATUS.CREATED)
2018-06-24 03:11:52 -05:00
.body_ok(API_MESSAGE.PKG_CREATED);
});
2018-06-22 18:03:25 -05:00
test(prefix + 'creating new package', () => {});
2018-12-16 15:30:49 -05:00
describe(`${pkg}`, () => {
2017-12-02 05:19:08 -05:00
beforeAll(function () {
return server2
.putVersion(pkg, '0.1.1', generatePkg(pkg))
2018-06-22 18:03:25 -05:00
.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 () {
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`, () => {
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`, () => {
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
}