0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-03 23:09:17 -05:00
verdaccio/test/functional/mirror.js

67 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
let assert = require('assert');
2013-12-19 19:11:54 +04:00
function readfile(x) {
2017-04-19 21:15:28 +02:00
return require('fs').readFileSync(__dirname + '/' + x);
2013-12-19 19:11:54 +04:00
}
module.exports = function() {
2017-04-19 21:15:28 +02:00
let server = process.server;
let server2 = process.server2;
2013-12-29 10:40:47 +04:00
2017-04-19 21:15:28 +02:00
it('testing anti-loop', function() {
return server2.get_package('testloop')
.status(404)
2017-04-19 21:15:28 +02:00
.body_error(/no such package/);
})
2013-12-19 19:11:54 +04:00
2017-04-19 21:15:28 +02:00
;['fwd'].forEach(function(pkg) {
let prefix = pkg + ': ';
pkg = 'test' + pkg;
2013-12-19 19:11:54 +04:00
describe(pkg, function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server.put_package(pkg, require('./lib/package')(pkg))
.status(201)
2017-04-19 21:15:28 +02:00
.body_ok(/created new package/);
});
2013-12-19 19:11:54 +04:00
2017-04-19 21:15:28 +02:00
it(prefix+'creating new package', function() {});
2013-12-19 19:11:54 +04:00
describe(pkg, function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server.put_version(pkg, '0.1.1', require('./lib/package')(pkg))
.status(201)
2017-04-19 21:15:28 +02:00
.body_ok(/published/);
});
2013-12-19 19:11:54 +04:00
2017-04-19 21:15:28 +02:00
it(prefix+'uploading new package version', function() {});
2013-12-19 19:11:54 +04:00
2017-04-19 21:15:28 +02:00
it(prefix+'uploading incomplete tarball', function() {
return server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000);
});
2013-12-19 19:11:54 +04:00
describe('tarball', function() {
2017-04-19 21:15:28 +02:00
before(function() {
return server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'))
.status(201)
2017-04-19 21:15:28 +02:00
.body_ok(/.*/);
});
2013-12-19 19:11:54 +04:00
2017-04-19 21:15:28 +02:00
it(prefix+'uploading new tarball', function() {});
2013-12-29 10:40:47 +04:00
2017-04-19 21:15:28 +02:00
it(prefix+'downloading tarball from server1', function() {
return server.get_tarball(pkg, pkg+'.file')
.status(200)
2017-04-19 21:15:28 +02:00
.then(function(body) {
assert.deepEqual(body, readfile('fixtures/binary'));
});
});
});
});
});
});
};
2013-12-19 19:11:54 +04:00