0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/test/functional/scenarios/gh29.js
2018-06-24 10:11:52 +02:00

70 lines
2.2 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import {TARBALL} from '../config.functional';
import {HTTP_STATUS} from "../../../src/lib/constants";
import {createTarballHash} from "../../../src/lib/crypto-utils";
function readfile(filePath) {
const folder = path.join(__dirname , filePath);
return fs.readFileSync(folder);
}
const binary = '../fixtures/binary';
const pkgName = 'testpkg-gh29';
export default function (server, server2) {
describe('pkg-gh29 #1', () => {
test('downloading non-existent tarball #1 / srv2', () => {
return server2.getTarball(pkgName, TARBALL)
.status(HTTP_STATUS.NOT_FOUND)
.body_error(/no such package/);
});
});
describe('pkg-gh29 #2', () => {
beforeAll(function() {
return server.putPackage(pkgName, require('../fixtures/package')(pkgName))
.status(HTTP_STATUS.CREATED)
.body_ok(/created new package/);
});
test('creating new package / srv1', () => {});
test('downloading non-existent tarball #2 / srv2', () => {
return server2.getTarball(pkgName, TARBALL)
.status(HTTP_STATUS.NOT_FOUND)
.body_error(/no such file available/);
});
describe('tarball', () => {
beforeAll(function() {
return server.putTarball(pkgName, TARBALL, readfile(binary))
.status(HTTP_STATUS.CREATED)
.body_ok(/.*/);
});
test('uploading new tarball / srv1', () => {});
describe('pkg version', () => {
beforeAll(function() {
const pkg = require('../fixtures/package')(pkgName);
pkg.dist.shasum = createTarballHash().update(readfile(binary)).digest('hex');
return server.putVersion(pkgName, '0.0.1', pkg)
.status(HTTP_STATUS.CREATED)
.body_ok(/published/);
});
test('uploading new package version / srv1', () => {});
test('downloading newly created tarball / srv2', () => {
return server2.getTarball(pkgName, TARBALL)
.status(HTTP_STATUS.OK)
.then(function(body) {
expect(body).toEqual(readfile(binary));
});
});
});
});
});
}