1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00
verdaccio/test/mirror.js

76 lines
2.1 KiB
JavaScript
Raw Normal View History

2013-12-13 15:00:46 +01:00
var assert = require('assert')
, readfile = require('fs').readFileSync
, ex = module.exports
, server = process.server
, server2 = process.server2
2013-12-09 04:59:31 +01:00
ex['testing anti-loop'] = function(cb) {
server2.get_package('testloop', function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 404)
assert(~body.error.indexOf('no such package'))
cb()
})
}
2013-12-09 04:59:31 +01:00
;['fwd', /*'loop'*/].forEach(function(pkg) {
2013-12-13 15:00:46 +01:00
var prefix = pkg + ': '
pkg = 'test' + pkg
2013-09-28 18:46:55 +02:00
ex[prefix+'creating new package'] = function(cb) {
server.put_package(pkg, require('./lib/package')(pkg), function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('created new package'))
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'uploading new package version'] = function(cb) {
server.put_version(pkg, '0.1.1', require('./lib/package')(pkg), function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 201)
assert(~body.ok.indexOf('published'))
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'downloading package via server2'] = function(cb) {
server2.get_package(pkg, function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 200)
assert.equal(body.name, pkg)
assert.equal(body.versions['0.1.1'].name, pkg)
assert.equal(body.versions['0.1.1'].dist.tarball, 'http://localhost:55552/'+pkg+'/-/blahblah')
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'uploading incomplete tarball'] = function(cb) {
server.put_tarball_incomplete(pkg, pkg+'.bad', readfile('fixtures/binary'), 3000, function(res, body) {
2013-12-13 15:00:46 +01:00
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'uploading new tarball'] = function(cb) {
server.put_tarball(pkg, pkg+'.file', readfile('fixtures/binary'), function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 201)
assert(body.ok)
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'downloading tarball from server1'] = function(cb) {
server.get_tarball(pkg, pkg+'.file', function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 200)
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
cb()
})
}
2013-09-28 18:46:55 +02:00
ex[prefix+'downloading tarball from server2'] = function(cb) {
server2.get_tarball(pkg, pkg+'.file', function(res, body) {
2013-12-13 15:00:46 +01:00
assert.equal(res.statusCode, 200)
assert.deepEqual(body, readfile('fixtures/binary').toString('utf8'))
cb()
})
}
})
2013-09-28 13:14:51 +02:00