2017-04-19 21:15:28 +02:00
|
|
|
'use strict';
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-08-06 21:54:15 +02:00
|
|
|
require('../lib/startup');
|
2017-04-19 21:15:28 +02:00
|
|
|
|
2017-08-06 21:54:15 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
const crypto = require('crypto');
|
|
|
|
const util = require('../lib/test.utils');
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-08-06 21:54:15 +02:00
|
|
|
function getBinary() {
|
|
|
|
return util.readFile('../fixtures/binary');
|
2014-08-08 03:08:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = function() {
|
2017-08-06 21:54:15 +02:00
|
|
|
const server = process.server;
|
|
|
|
const server2 = process.server2;
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('trying to fetch non-existent package / null storage', function() {
|
2017-06-28 22:56:02 +02:00
|
|
|
return server.getPackage('test-nullstorage-nonexist')
|
2015-04-11 19:11:04 +02:00
|
|
|
.status(404)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_error(/no such package/);
|
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('test-nullstorage on server2', function() {
|
2017-04-19 21:15:28 +02:00
|
|
|
before(function() {
|
2017-06-28 22:56:02 +02:00
|
|
|
return server2.addPackage('test-nullstorage2');
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('creating new package - server2', function() {/* test for before() */});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('downloading non-existent tarball', function() {
|
2017-06-28 22:56:02 +02:00
|
|
|
return server.getTarball('test-nullstorage2', 'blahblah')
|
2015-04-11 19:11:04 +02:00
|
|
|
.status(404)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_error(/no such file/);
|
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2014-11-12 12:14:37 +01:00
|
|
|
describe('tarball', function() {
|
2017-04-19 21:15:28 +02:00
|
|
|
before(function() {
|
2017-08-06 21:54:15 +02:00
|
|
|
return server2.putTarball('test-nullstorage2', 'blahblah', getBinary())
|
2015-04-11 19:11:04 +02:00
|
|
|
.status(201)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_ok(/.*/);
|
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
before(function() {
|
2017-08-06 21:54:15 +02:00
|
|
|
let pkg = require('../fixtures/package')('test-nullstorage2');
|
|
|
|
pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex');
|
2017-06-28 22:56:02 +02:00
|
|
|
return server2.putVersion('test-nullstorage2', '0.0.1', pkg)
|
2015-04-11 19:11:04 +02:00
|
|
|
.status(201)
|
2017-04-19 21:15:28 +02:00
|
|
|
.body_ok(/published/);
|
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('uploading new tarball', function() {/* test for before() */});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('downloading newly created tarball', function() {
|
2017-06-28 22:56:02 +02:00
|
|
|
return server.getTarball('test-nullstorage2', 'blahblah')
|
2015-04-11 19:11:04 +02:00
|
|
|
.status(200)
|
2017-04-19 21:15:28 +02:00
|
|
|
.then(function(body) {
|
2017-08-06 21:54:15 +02:00
|
|
|
assert.deepEqual(body, getBinary());
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
|
|
|
});
|
2014-08-08 03:08:41 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
it('downloading newly created package', function() {
|
2017-06-28 22:56:02 +02:00
|
|
|
return server.getPackage('test-nullstorage2')
|
2015-04-11 19:11:04 +02:00
|
|
|
.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'});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2014-08-08 03:08:41 +02:00
|
|
|
|