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

74 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
2017-04-19 21:15:28 +02:00
require('./lib/startup');
let assert = require('assert');
let crypto = require('crypto');
function readfile(x) {
2017-04-19 21:15:28 +02:00
return require('fs').readFileSync(__dirname + '/' + x);
}
module.exports = function() {
2017-04-19 21:15:28 +02:00
let server = process.server;
let server2 = process.server2;
2017-04-19 21:15:28 +02:00
it('trying to fetch non-existent package / null storage', function() {
return server.get_package('test-nullstorage-nonexist')
.status(404)
2017-04-19 21:15:28 +02:00
.body_error(/no such package/);
});
describe('test-nullstorage on server2', function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server2.add_package('test-nullstorage2');
});
2017-04-19 21:15:28 +02:00
it('creating new package - server2', function() {/* test for before() */});
2017-04-19 21:15:28 +02:00
it('downloading non-existent tarball', function() {
return server.get_tarball('test-nullstorage2', 'blahblah')
.status(404)
2017-04-19 21:15:28 +02:00
.body_error(/no such file/);
});
describe('tarball', function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server2.put_tarball('test-nullstorage2', 'blahblah', readfile('fixtures/binary'))
.status(201)
2017-04-19 21:15:28 +02:00
.body_ok(/.*/);
});
2017-04-19 21:15:28 +02:00
before(function() {
let pkg = require('./lib/package')('test-nullstorage2');
pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex');
return server2.put_version('test-nullstorage2', '0.0.1', pkg)
.status(201)
2017-04-19 21:15:28 +02:00
.body_ok(/published/);
});
2017-04-19 21:15:28 +02:00
it('uploading new tarball', function() {/* test for before() */});
2017-04-19 21:15:28 +02:00
it('downloading newly created tarball', function() {
return server.get_tarball('test-nullstorage2', 'blahblah')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
assert.deepEqual(body, readfile('fixtures/binary'));
});
});
2017-04-19 21:15:28 +02:00
it('downloading newly created package', function() {
return server.get_package('test-nullstorage2')
.status(200)
2017-04-19 21:15:28 +02: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'});
});
});
});
});
};