0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-13 22:48:31 -05:00
verdaccio/test/mirror.js
2013-09-28 14:59:05 +04:00

71 lines
2.1 KiB
JavaScript

var assert = require('assert');
var readfile = require('fs').readFileSync;
var ex = module.exports;
var server = process.server;
var server2 = process.server2;
ex['creating new package'] = function(cb) {
server.put_package('testfwd', readfile('fixtures/fwd-package.json'), function(res, body) {
assert(res.statusCode === 201);
assert(~body.ok.indexOf('created new package'));
cb();
});
};
ex['uploading new package version'] = function(cb) {
server.put_version('testfwd', '0.1.1', readfile('fixtures/fwd-package.json'), function(res, body) {
assert(res.statusCode === 201);
assert(~body.ok.indexOf('published'));
cb();
});
};
ex['downloading package via server2'] = function(cb) {
server2.get_package('testfwd', function(res, body) {
assert.equal(res.statusCode, 200);
assert.equal(body.name, 'testfwd');
assert.equal(body.versions['0.1.1'].name, 'testfwd');
assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/testpkg/-/blahblah');
cb();
});
};
/*
ex['creating - srv1 (remove it)'] = function(cb) {
server.put_package('testfwd', readfile('fixtures/fwd-package.json'), function(res, body) {
assert(res.statusCode === 201);
assert(~body.ok.indexOf('created new package'));
cb();
});
};
ex['creating - srv2 (remove it)'] = function(cb) {
server2.put_package('testfwd', readfile('fixtures/fwd-package.json'), function(res, body) {
assert(res.statusCode === 201);
assert(~body.ok.indexOf('created new package'));
cb();
});
};
ex['uploading incomplete tarball'] = function(cb) {
server.put_tarball_incomplete('testfwd', 'testfwd.bad', readfile('fixtures/binary'), 3000, function(res, body) {
cb();
});
};
ex['uploading new tarball'] = function(cb) {
server.put_tarball('testfwd', 'testfwd.file', readfile('fixtures/binary'), function(res, body) {
assert(res.statusCode === 201);
assert(body.ok);
cb();
});
};
ex['downloading tarball from server2'] = function(cb) {
server2.get_tarball('testfwd', 'testfwd.file', function(res, body) {
assert(res.statusCode === 200);
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'));
cb();
});
};
*/