0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/functional/sanity/nullstorage.js

68 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-12-02 05:19:08 -05:00
import assert from 'assert';
import crypto from 'crypto';
import {readFile} from '../lib/test.utils';
function getBinary() {
2017-12-02 05:19:08 -05:00
return readFile('../fixtures/binary');
}
2017-12-02 05:19:08 -05:00
export default function (server, server2) {
2017-12-02 05:19:08 -05:00
test('trying to fetch non-existent package / null storage', () => {
return server.getPackage('test-nullstorage-nonexist')
.status(404)
2017-04-19 14:15:28 -05:00
.body_error(/no such package/);
});
2017-12-02 05:19:08 -05:00
describe('test-nullstorage on server2', () => {
beforeAll(function() {
return server2.addPackage('test-nullstorage2');
2017-04-19 14:15:28 -05:00
});
2017-12-02 05:19:08 -05:00
test('creating new package - server2', () => {/* test for before() */});
2017-12-02 05:19:08 -05:00
test('downloading non-existent tarball', () => {
return server.getTarball('test-nullstorage2', 'blahblah')
.status(404)
2017-04-19 14:15:28 -05:00
.body_error(/no such file/);
});
2017-12-02 05:19:08 -05:00
describe('tarball', () => {
beforeAll(function() {
return server2.putTarball('test-nullstorage2', 'blahblah', getBinary())
.status(201)
2017-04-19 14:15:28 -05:00
.body_ok(/.*/);
});
2017-12-02 05:19:08 -05:00
beforeAll(function() {
let pkg = require('../fixtures/package')('test-nullstorage2');
pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex');
return server2.putVersion('test-nullstorage2', '0.0.1', pkg)
.status(201)
2017-04-19 14:15:28 -05:00
.body_ok(/published/);
});
2017-12-02 05:19:08 -05:00
test('uploading new tarball', () => {/* test for before() */});
2017-12-02 05:19:08 -05:00
test('downloading newly created tarball', () => {
return server.getTarball('test-nullstorage2', 'blahblah')
.status(200)
2017-04-19 14:15:28 -05:00
.then(function(body) {
assert.deepEqual(body, getBinary());
2017-04-19 14:15:28 -05:00
});
});
2017-12-02 05:19:08 -05:00
test('downloading newly created package', () => {
return server.getPackage('test-nullstorage2')
.status(200)
2017-04-19 14:15:28 -05:00
.then(function(body) {
assert.equal(body.name, 'test-nullstorage2');
assert.equal(body.versions['0.0.1'].name, 'test-nullstorage2');
assert.equal(body.versions['0.0.1'].dist.tarball, 'http://localhost:55551/test-nullstorage2/-/blahblah');
assert.deepEqual(body['dist-tags'], {latest: '0.0.1'});
});
});
});
});
2017-12-02 05:19:08 -05:00
}