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

71 lines
2.2 KiB
JavaScript
Raw Normal View History

import {createTarballHash} from "../../../src/lib/crypto-utils";
import {HTTP_STATUS} from "../../../src/lib/constants";
import fs from 'fs';
import path from 'path';
2018-06-23 08:35:06 +02:00
import {TARBALL} from '../config.func';
2013-12-19 16:11:54 +01:00
function readfile(filePath) {
const folder = path.join(__dirname , filePath);
return fs.readFileSync(folder);
2013-12-19 16:11:54 +01:00
}
const binary = '../fixtures/binary';
const pkgName = 'testpkg-gh29';
2017-12-02 11:19:08 +01:00
export default function (server, server2) {
2018-06-23 01:03:25 +02:00
describe('pkg-gh29 #1', () => {
test('downloading non-existent tarball #1 / srv2', () => {
2018-06-23 08:35:06 +02:00
return server2.getTarball(pkgName, TARBALL)
2018-06-23 01:03:25 +02:00
.status(HTTP_STATUS.NOT_FOUND)
.body_error(/no such package/);
});
2017-04-19 21:15:28 +02:00
});
2013-12-19 16:11:54 +01:00
2018-06-23 01:03:25 +02:00
describe('pkg-gh29 #2', () => {
2017-12-02 11:19:08 +01:00
beforeAll(function() {
return server.putPackage(pkgName, require('../fixtures/package')(pkgName))
.status(HTTP_STATUS.CREATED)
2017-04-19 21:15:28 +02:00
.body_ok(/created new package/);
});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
test('creating new package / srv1', () => {});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
test('downloading non-existent tarball #2 / srv2', () => {
2018-06-23 08:35:06 +02:00
return server2.getTarball(pkgName, TARBALL)
.status(HTTP_STATUS.NOT_FOUND)
.body_error(/no such file available/);
2017-04-19 21:15:28 +02:00
});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
describe('tarball', () => {
beforeAll(function() {
2018-06-23 08:35:06 +02:00
return server.putTarball(pkgName, TARBALL, readfile(binary))
.status(HTTP_STATUS.CREATED)
2017-04-19 21:15:28 +02:00
.body_ok(/.*/);
});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
test('uploading new tarball / srv1', () => {});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
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)
2017-04-19 21:15:28 +02:00
.body_ok(/published/);
});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
test('uploading new package version / srv1', () => {});
2013-12-19 16:11:54 +01:00
2017-12-02 11:19:08 +01:00
test('downloading newly created tarball / srv2', () => {
2018-06-23 08:35:06 +02:00
return server2.getTarball(pkgName, TARBALL)
.status(HTTP_STATUS.OK)
.then(function(body) {
expect(body).toEqual(readfile(binary));
});
2017-04-19 21:15:28 +02:00
});
});
});
});
2017-12-02 11:19:08 +01:00
}