mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
refactor: scoped packages unit test, relocate other unit test
This commit is contained in:
parent
1e6c7dd6ea
commit
a038b282ec
4 changed files with 80 additions and 75 deletions
|
@ -68,10 +68,10 @@ describe('Create registry servers', function() {
|
|||
require('./nullstorage')();
|
||||
require('./race')();
|
||||
require('./racycrash')();
|
||||
require('./package/scoped')();
|
||||
require('./package/scoped.spec')();
|
||||
require('./security')();
|
||||
require('./adduser')();
|
||||
require('./logout')();
|
||||
require('./auth/logout')();
|
||||
require('./addtag')();
|
||||
require('./plugins')();
|
||||
require('./notify')();
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const utils = require ('../lib/test.utils');
|
||||
|
||||
module.exports = function() {
|
||||
let server = process.server;
|
||||
let server2 = process.server2;
|
||||
|
||||
describe('test-scoped', function() {
|
||||
before(function() {
|
||||
return server.request({
|
||||
uri: '/@test%2fscoped',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
method: 'PUT',
|
||||
json: require('./scoped.json'),
|
||||
}).status(201);
|
||||
});
|
||||
|
||||
it('add pkg', function() {});
|
||||
|
||||
it('server1 - tarball', function() {
|
||||
return server.getTarball('@test/scoped', 'scoped-1.0.0.tgz')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
// not real sha due to utf8 conversion
|
||||
assert.strictEqual(utils.generateSha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
||||
});
|
||||
});
|
||||
|
||||
it('server2 - tarball', function() {
|
||||
return server2.getTarball('@test/scoped', 'scoped-1.0.0.tgz')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
// not real sha due to utf8 conversion
|
||||
assert.strictEqual(utils.generateSha(body), '6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
||||
});
|
||||
});
|
||||
|
||||
it('server1 - package', function() {
|
||||
return server.getPackage('@test/scoped')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
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'});
|
||||
});
|
||||
});
|
||||
|
||||
it('server2 - package', function() {
|
||||
return server2.getPackage('@test/scoped')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
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'});
|
||||
});
|
||||
});
|
||||
|
||||
it('server2 - nginx workaround', function() {
|
||||
return server2.request({uri: '/@test/scoped/1.0.0'})
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
assert.equal(body.name, '@test/scoped');
|
||||
assert.equal(body.dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
78
test/functional/package/scoped.spec.js
Normal file
78
test/functional/package/scoped.spec.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const utils = require ('../lib/test.utils');
|
||||
|
||||
module.exports = function() {
|
||||
const server = process.server;
|
||||
const server2 = process.server2;
|
||||
|
||||
describe('test-scoped', function() {
|
||||
before(function() {
|
||||
return server.request({
|
||||
uri: '/@test%2fscoped',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
method: 'PUT',
|
||||
json: require('./scoped.json'),
|
||||
}).status(201);
|
||||
});
|
||||
|
||||
it('should publish scope package', function() {});
|
||||
|
||||
describe('should get scoped packages tarball', () => {
|
||||
const uploadScopedTarBall = (server) => {
|
||||
return server.getTarball('@test/scoped', 'scoped-1.0.0.tgz')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
// not real sha due to utf8 conversion
|
||||
assert.strictEqual(utils.generateSha(body),
|
||||
'6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
||||
});
|
||||
};
|
||||
|
||||
it('should be a scoped tarball from server1', () => {
|
||||
return uploadScopedTarBall(server);
|
||||
});
|
||||
|
||||
it('should be a scoped tarball from server2', () => {
|
||||
return uploadScopedTarBall(server2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('should retrieve scoped packages', function() {
|
||||
const testScopePackage = (server, port) => server.getPackage('@test/scoped')
|
||||
.status(200)
|
||||
.then(function(body) {
|
||||
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:${port}/@test%2fscoped/-/scoped-1.0.0.tgz`);
|
||||
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'});
|
||||
});
|
||||
|
||||
it('scoped package on server1', () => {
|
||||
return testScopePackage(server, '55551');
|
||||
});
|
||||
|
||||
it('scoped package on server2', () => {
|
||||
return testScopePackage(server2, '55552');
|
||||
});
|
||||
});
|
||||
|
||||
describe('should retrieve a scoped packages under nginx', function() {
|
||||
it('should work nginx workaround', () => {
|
||||
return server2.request({
|
||||
uri: '/@test/scoped/1.0.0'
|
||||
}).status(200)
|
||||
.then(function(body) {
|
||||
assert.equal(body.name, '@test/scoped');
|
||||
assert.equal(body.dist.tarball,
|
||||
'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue