0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-17 23:45:29 -05:00

add tests for scoped packages

This commit is contained in:
Alex Kocharin 2014-12-14 23:29:56 +03:00
parent ea50f3d3ed
commit c07d819ce9
6 changed files with 86 additions and 1 deletions

View file

@ -23,6 +23,11 @@ logs:
- {type: stdout, format: pretty, level: trace}
packages:
'@test/*':
allow_access: all
allow_publish: all
proxy: server2
'testfwd*':
allow_access: all
allow_publish: all

View file

@ -16,6 +16,11 @@ logs:
- {type: stdout, format: pretty, level: trace}
packages:
'@test/*':
allow_access: all
allow_publish: all
proxy: server1
'testfwd':
allow_access: all
allow_publish: all

View file

@ -0,0 +1 @@
{"_id":"@test/scoped","name":"@test/scoped","description":"test... test... test...","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@test/scoped","version":"1.0.0","description":"test... test... test...","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"ISC","readme":"ERROR: No README data found!","_id":"@test/scoped@1.0.0","_shasum":"6e67b14e2c0e450b942e2bc8086b49e90f594790","_from":".","_npmVersion":"2.0.1","_nodeVersion":"0.10.25","_npmUser":{},"dist":{"shasum":"6e67b14e2c0e450b942e2bc8086b49e90f594790","tarball":"http://localhost:4873/@test/scoped/-/@test/scoped-1.0.0.tgz"}}},"readme":"ERROR: No README data found!","_attachments":{"@test/scoped-1.0.0.tgz":{"content_type":"application/octet-stream","data":"H4sIAAAAAAAAAytITM5OTE/VL4DQelnF+XkMVAYGBgZmZiYKQNrQ3NQAmQYDYwMg29DIxMTY2Mzc1NSYwcDQ2MDIDChPbYdgA6XFJYlFQKdQag7ELwpweoiAaqW8xNxUJSslh5LU4hL94uT8gtQUJR2lstSi4sz8PKCEoZ6BngFQJCW1OLkos6AEIgpSraenp4BGA9XlJmaCFGTmpaRWAJMTUASir1jJqhqsDSiZmpyRrxCj5FpUlF9kpZCXD9auUFyQmpyZlpmaEqOkoKamkFqRWaJgqFSro5RYWpKRXwTUBzQsJzM5Na8Y5GLPYGel2oEOv6EOCtDyf2Vibg617SCQ/41MzZHyv+Fo/qcnAOV+KwXU3M8FzfxWCuC8z4WU863QMzyM5gJleysFWK7nguZ5Ky4FsAqgFaTkeS5IjgfqUuKCZngrBWB+5xro4Bp2AJb/QZGhC4l/XXCs65WkV1HJDgL539QAOf8bmwHzv4khWD2V7McLRnj+l+/mgDCY307enXXYQKTN+LUmn5QRq/u+5mVOLy/szBZTXN1764bRpKAgp3t7j08XuS7itTLT4+P+P49iligvXC/2ydVmZendyg9vfLbOiOjZqOPNYHsm2OxLmOHhUglVT5n0Sql0brFjOqcM7b8qxGe+37PB4lT+95fvmOTrVK0ueU3pKqp6PPVztrrvWq5di9afssrV8mlh5JZw43q65OrW94t8SwVYDIrWaLfmcZWErmCuU+8pqe37lHy7zVN1O5vZl3NRyZYhy3LZw7VXym/VMhOZ5h3A/lZxyXJR0er9pmK/CzbPnbaq6OyR7/zbv5S8/L677Kryv/suO2f/6sn/0X+p5kC9RPmfdOP/9Qvb6vjmv1S3/SMT9e1kQ40d2783Sw7OOzyz6pLxec4tohVH/Geoy3684erJb8P+ZG7Mr51pZ2eZvr7/QpbVdU4yA8/ARuEoGAWjYBSQBQDM0BedABAAAA==","length":736}}}

View file

@ -59,6 +59,7 @@ describe('Func', function() {
require('./nullstorage')()
require('./race')()
require('./racycrash')()
require('./scoped')()
require('./security')()
require('./adduser')()
require('./addtag')()

View file

@ -50,7 +50,7 @@ Server.prototype.auth = function(user, pass, cb) {
Server.prototype.get_package = function(name, cb) {
this.request({
uri: '/'+name,
uri: '/'+encodeURIComponent(name),
method: 'GET',
}, prep(cb))
}

73
test/functional/scoped.js Normal file
View file

@ -0,0 +1,73 @@
var assert = require('assert')
function readfile(x) {
return require('fs').readFileSync(__dirname + '/' + x)
}
function sha(x) {
return require('crypto').createHash('sha1', 'binary').update(x).digest('hex')
}
module.exports = function() {
var server = process.server
var server2 = process.server2
var express = process.express
describe('test-scoped', function() {
before(function(cb) {
server.request({
uri: '/@test%2fscoped',
headers: {
'content-type': 'application/json',
},
method: 'PUT',
json: JSON.parse(readfile('fixtures/scoped.json')),
}, function(err, res, body) {
assert.equal(res.statusCode, 201)
cb()
})
})
it('add pkg', function(){})
it('server1 - tarball', function(cb) {
server.get_tarball('@test/scoped', 'scoped-1.0.0.tgz', function(res, body) {
assert.equal(res.statusCode, 200)
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), 'c59298948907d077c3b42f091554bdeea9208964')
cb()
})
})
it('server2 - tarball', function(cb) {
server2.get_tarball('@test/scoped', 'scoped-1.0.0.tgz', function(res, body) {
assert.equal(res.statusCode, 200)
// not real sha due to utf8 conversion
assert.strictEqual(sha(body), 'c59298948907d077c3b42f091554bdeea9208964')
cb()
})
})
it('server1 - package', function(cb) {
server.get_package('@test/scoped', function(res, body) {
assert.equal(res.statusCode, 200)
assert.equal(body.name, '@test/scoped')
assert.equal(body.versions['1.0.0'].name, '@test/scoped')
assert.equal(body.versions['1.0.0'].dist.tarball, 'http://localhost:55551/@test%2fscoped/-/scoped-1.0.0.tgz')
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'})
cb()
})
})
it('server2 - package', function(cb) {
server2.get_package('@test/scoped', function(res, body) {
assert.equal(res.statusCode, 200)
assert.equal(body.name, '@test/scoped')
assert.equal(body.versions['1.0.0'].name, '@test/scoped')
assert.equal(body.versions['1.0.0'].dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz')
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'})
cb()
})
})
})
}