2018-06-19 15:02:29 -05:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
2018-06-24 03:11:52 -05:00
|
|
|
import {TARBALL} from '../config.functional';
|
2018-06-23 04:51:58 -05:00
|
|
|
import {HTTP_STATUS} from "../../../src/lib/constants";
|
|
|
|
import {createTarballHash} from "../../../src/lib/crypto-utils";
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2018-06-19 15:02:29 -05:00
|
|
|
function readfile(filePath) {
|
|
|
|
const folder = path.join(__dirname , filePath);
|
|
|
|
|
|
|
|
return fs.readFileSync(folder);
|
2013-12-19 10:11:54 -05:00
|
|
|
}
|
|
|
|
|
2018-06-19 15:02:29 -05:00
|
|
|
const binary = '../fixtures/binary';
|
2018-06-19 14:21:25 -05:00
|
|
|
const pkgName = 'testpkg-gh29';
|
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
export default function (server, server2) {
|
2018-06-22 18:03:25 -05:00
|
|
|
describe('pkg-gh29 #1', () => {
|
|
|
|
test('downloading non-existent tarball #1 / srv2', () => {
|
2018-06-23 01:35:06 -05:00
|
|
|
return server2.getTarball(pkgName, TARBALL)
|
2018-06-22 18:03:25 -05:00
|
|
|
.status(HTTP_STATUS.NOT_FOUND)
|
|
|
|
.body_error(/no such package/);
|
|
|
|
});
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2018-06-22 18:03:25 -05:00
|
|
|
describe('pkg-gh29 #2', () => {
|
2017-12-02 05:19:08 -05:00
|
|
|
beforeAll(function() {
|
2018-06-19 15:02:29 -05:00
|
|
|
return server.putPackage(pkgName, require('../fixtures/package')(pkgName))
|
|
|
|
.status(HTTP_STATUS.CREATED)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/created new package/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('creating new package / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('downloading non-existent tarball #2 / srv2', () => {
|
2018-06-23 01:35:06 -05:00
|
|
|
return server2.getTarball(pkgName, TARBALL)
|
2018-06-19 15:02:29 -05:00
|
|
|
.status(HTTP_STATUS.NOT_FOUND)
|
2018-01-27 20:40:07 -05:00
|
|
|
.body_error(/no such file available/);
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('tarball', () => {
|
|
|
|
beforeAll(function() {
|
2018-06-23 01:35:06 -05:00
|
|
|
return server.putTarball(pkgName, TARBALL, readfile(binary))
|
2018-06-19 15:02:29 -05:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/.*/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('uploading new tarball / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
describe('pkg version', () => {
|
|
|
|
beforeAll(function() {
|
2018-06-19 15:02:29 -05:00
|
|
|
const pkg = require('../fixtures/package')(pkgName);
|
2018-06-19 14:21:25 -05:00
|
|
|
pkg.dist.shasum = createTarballHash().update(readfile(binary)).digest('hex');
|
|
|
|
return server.putVersion(pkgName, '0.0.1', pkg)
|
2018-06-19 15:02:29 -05:00
|
|
|
.status(HTTP_STATUS.CREATED)
|
2017-04-19 14:15:28 -05:00
|
|
|
.body_ok(/published/);
|
|
|
|
});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('uploading new package version / srv1', () => {});
|
2013-12-19 10:11:54 -05:00
|
|
|
|
2017-12-02 05:19:08 -05:00
|
|
|
test('downloading newly created tarball / srv2', () => {
|
2018-06-23 01:35:06 -05:00
|
|
|
return server2.getTarball(pkgName, TARBALL)
|
2018-06-19 15:02:29 -05:00
|
|
|
.status(HTTP_STATUS.OK)
|
2018-01-27 20:40:07 -05:00
|
|
|
.then(function(body) {
|
2018-06-19 14:21:25 -05:00
|
|
|
expect(body).toEqual(readfile(binary));
|
2018-01-27 20:40:07 -05:00
|
|
|
});
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-02 05:19:08 -05:00
|
|
|
}
|