0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-13 22:48:31 -05:00
verdaccio/test/functional/gh29.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

import {createTarballHash} from "../../src/lib/crypto-utils";
2013-12-19 10:11:54 -05:00
function readfile(x) {
2017-04-19 14:15:28 -05:00
return require('fs').readFileSync(__dirname + '/' + x);
2013-12-19 10:11:54 -05:00
}
const binary = 'fixtures/binary';
const pkgName = 'testpkg-gh29';
const pkgContent = 'blahblah';
2017-12-02 05:19:08 -05:00
export default function (server, server2) {
2013-12-29 01:40:47 -05:00
2017-12-02 05:19:08 -05:00
test('downloading non-existent tarball #1 / srv2', () => {
return server2.getTarball(pkgName, pkgContent)
.status(404)
2017-04-19 14:15:28 -05:00
.body_error(/no such package/);
});
2013-12-19 10:11:54 -05:00
2017-12-02 05:19:08 -05:00
describe('pkg-gh29', () => {
2017-12-02 05:19:08 -05:00
beforeAll(function() {
return server.putPackage(pkgName, require('./fixtures/package')(pkgName))
.status(201)
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', () => {
return server2.getTarball(pkgName, pkgContent)
.status(404)
.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() {
return server.putTarball(pkgName, pkgContent, readfile(binary))
.status(201)
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() {
const pkg = require('./fixtures/package')(pkgName);
pkg.dist.shasum = createTarballHash().update(readfile(binary)).digest('hex');
return server.putVersion(pkgName, '0.0.1', pkg)
.status(201)
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', () => {
return server2.getTarball(pkgName, pkgContent)
.status(200)
.then(function(body) {
expect(body).toEqual(readfile(binary));
});
2017-04-19 14:15:28 -05:00
});
});
});
});
2017-12-02 05:19:08 -05:00
}