mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-17 07:45:52 +01:00
66f4197236
* chore: test * chore: add * chore: more progress * chore: progress in migration, fix prettier parser * chore: reduce tsc errors * chore: refactor storage utils types * chore: refactor utils types * chore: refactor local storage types * chore: refactor config utils types * chore: refactor tsc types * refactor: apply eslint fix, tabs etc * chore: fix lint errors * test: update unit test conf to typescript setup few test refactored to typescript * chore: enable more unit test migrate to typescript * chore: migrate storage test to tsc * chore: migrate up storage test to tsc * refactor: enable plugin and auth test * chore: migrate plugin loader test * chore: update dependencies * chore: migrate functional test to typescript * chore: add codecove * chore: update express * chore: downgrade puppeteer The latest version does not seems to work properly fine. * chore: update dependencies
97 lines
2.6 KiB
TypeScript
97 lines
2.6 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import crypto from 'crypto';
|
|
import { readFile } from '../lib/test.utils';
|
|
import {HTTP_STATUS} from "../../../src/lib/constants";
|
|
import {TARBALL} from '../config.functional';
|
|
import { createTarballHash } from '../../../src/lib/crypto-utils';
|
|
import requirePackage from '../fixtures/package';
|
|
|
|
function getBinary() {
|
|
return readFile('../fixtures/binary');
|
|
}
|
|
|
|
const STORAGE = '../store/test-storage3';
|
|
const PKG_GH131 = 'pkg-gh131';
|
|
const PKG_GH1312 = 'pkg-gh1312';
|
|
|
|
function isCached(pkgName, tarballName) {
|
|
const pathCached = path.join(__dirname, STORAGE, pkgName, tarballName);
|
|
console.log('isCached =>', pathCached);
|
|
|
|
return fs.existsSync(pathCached);
|
|
}
|
|
|
|
export default function (server, server2, server3) {
|
|
|
|
describe('storage tarball cache test', () => {
|
|
|
|
//more info #131
|
|
beforeAll(function () {
|
|
return server.addPackage(PKG_GH131);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server.putTarball(PKG_GH131, TARBALL, getBinary())
|
|
.status(HTTP_STATUS.CREATED)
|
|
.body_ok(/.*/);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
const pkg = requirePackage(PKG_GH131);
|
|
pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex');
|
|
|
|
return server.putVersion(PKG_GH131, '0.0.1', pkg)
|
|
.status(HTTP_STATUS.CREATED)
|
|
.body_ok(/published/);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server3.getPackage(PKG_GH131).status(HTTP_STATUS.OK);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server3.getTarball(PKG_GH131, TARBALL)
|
|
.status(HTTP_STATUS.OK);
|
|
});
|
|
|
|
test('should be caching packages from uplink server1', () => {
|
|
expect(isCached(PKG_GH131, TARBALL)).toEqual(true);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server2.addPackage(PKG_GH1312);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server2.putTarball(PKG_GH1312, TARBALL, getBinary())
|
|
.status(HTTP_STATUS.CREATED)
|
|
.body_ok(/.*/);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
const pkg = requirePackage(PKG_GH1312);
|
|
pkg.dist.shasum = createTarballHash().update(getBinary()).digest('hex');
|
|
|
|
return server2.putVersion(PKG_GH1312, '0.0.1', pkg)
|
|
.status(HTTP_STATUS.CREATED)
|
|
.body_ok(/published/);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server3.getPackage(PKG_GH1312)
|
|
.status(HTTP_STATUS.OK);
|
|
});
|
|
|
|
beforeAll(function () {
|
|
return server3.getTarball(PKG_GH1312, TARBALL)
|
|
.status(HTTP_STATUS.OK);
|
|
});
|
|
|
|
test('must not be caching packages from uplink server2', () => {
|
|
expect(isCached(PKG_GH1312, TARBALL)).toEqual(false);
|
|
});
|
|
|
|
});
|
|
}
|