mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
refactor: local database methods are async
This commit is contained in:
parent
102fa22507
commit
848e004eb5
7 changed files with 274 additions and 265 deletions
|
@ -16,7 +16,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@verdaccio/file-locking": "0.0.5",
|
||||
"@verdaccio/local-storage": "0.4.2",
|
||||
"@verdaccio/local-storage": "1.0.1",
|
||||
"@verdaccio/streams": "1.0.0",
|
||||
"JSONStream": "1.3.2",
|
||||
"async": "2.6.0",
|
||||
|
@ -51,7 +51,7 @@
|
|||
"@commitlint/cli": "6.1.3",
|
||||
"@commitlint/config-conventional": "6.1.3",
|
||||
"@commitlint/travis-cli": "6.1.3",
|
||||
"@verdaccio/types": "2.0.5",
|
||||
"@verdaccio/types": "2.1.0",
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-core": "6.26.0",
|
||||
"babel-eslint": "8.2.2",
|
||||
|
|
|
@ -8,7 +8,7 @@ import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageH
|
|||
function addSearchWebApi(route: Router, storage: IStorageHandler, auth: IAuth) {
|
||||
// Search package
|
||||
route.get('/search/:anything', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
const results = Search.query(req.params.anything);
|
||||
const results: any = Search.query(req.params.anything);
|
||||
const packages = [];
|
||||
|
||||
const getPackageInfo = function(i) {
|
||||
|
|
|
@ -98,19 +98,20 @@ class LocalStorage implements IStorage {
|
|||
|
||||
data = normalizePackage(data);
|
||||
|
||||
const removeFailed = this.localData.remove(name);
|
||||
|
||||
if (removeFailed) {
|
||||
// This will happen when database is locked
|
||||
return callback(ErrorCode.get422(removeFailed.message));
|
||||
}
|
||||
storage.deletePackage(pkgFileName, (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
this.localData.remove(name, (removeFailed) => {
|
||||
if (removeFailed) {
|
||||
// This will happen when database is locked
|
||||
return callback(ErrorCode.get422(removeFailed.message));
|
||||
}
|
||||
const attachments = Object.keys(data._attachments);
|
||||
|
||||
this._deleteAttachments(storage, attachments, callback);
|
||||
storage.deletePackage(pkgFileName, (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
const attachments = Object.keys(data._attachments);
|
||||
|
||||
this._deleteAttachments(storage, attachments, callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -254,12 +255,14 @@ class LocalStorage implements IStorage {
|
|||
data.versions[version] = metadata;
|
||||
tagVersion(data, version, tag);
|
||||
|
||||
let addFailed = this.localData.add(name);
|
||||
if (addFailed) {
|
||||
return cb(ErrorCode.get422(addFailed.message));
|
||||
}
|
||||
this.localData.add(name, (addFailed) => {
|
||||
if (addFailed) {
|
||||
return cb(ErrorCode.get422(addFailed.message));
|
||||
}
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
cb();
|
||||
}, callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,10 @@ class Search implements IWebSearch {
|
|||
*/
|
||||
query(query: string) {
|
||||
return query === '*'
|
||||
? this.storage.localStorage.localData.get().map( function( pkg ) {
|
||||
return {ref: pkg, score: 1};
|
||||
? this.storage.localStorage.localData.get((items) => {
|
||||
items.map( function( pkg ) {
|
||||
return {ref: pkg, score: 1};
|
||||
});
|
||||
}) : this.index.search(query);
|
||||
}
|
||||
|
||||
|
|
|
@ -495,34 +495,38 @@ class Storage implements IStorageHandler {
|
|||
*/
|
||||
getLocalDatabase(callback: Callback) {
|
||||
let self = this;
|
||||
let locals = this.localStorage.localData.get();
|
||||
let packages = [];
|
||||
this.localStorage.localData.get((err, locals) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
}
|
||||
|
||||
const getPackage = function(i) {
|
||||
self.localStorage.getPackageMetadata(locals[i], function(err, info) {
|
||||
if (_.isNil(err)) {
|
||||
const latest = info[DIST_TAGS].latest;
|
||||
let packages = [];
|
||||
const getPackage = function(itemPkg) {
|
||||
self.localStorage.getPackageMetadata(locals[itemPkg], function(err, info) {
|
||||
if (_.isNil(err)) {
|
||||
const latest = info[DIST_TAGS].latest;
|
||||
|
||||
if (latest && info.versions[latest]) {
|
||||
packages.push(info.versions[latest]);
|
||||
} else {
|
||||
self.logger.warn( {package: locals[i]}, 'package @{package} does not have a "latest" tag?' );
|
||||
if (latest && info.versions[latest]) {
|
||||
packages.push(info.versions[latest]);
|
||||
} else {
|
||||
self.logger.warn( {package: locals[itemPkg]}, 'package @{package} does not have a "latest" tag?' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= locals.length - 1) {
|
||||
callback(null, packages);
|
||||
} else {
|
||||
getPackage(i + 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (itemPkg >= locals.length - 1) {
|
||||
callback(null, packages);
|
||||
} else {
|
||||
getPackage(itemPkg + 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (locals.length) {
|
||||
getPackage(0);
|
||||
} else {
|
||||
callback(null, []);
|
||||
}
|
||||
if (locals.length) {
|
||||
getPackage(0);
|
||||
} else {
|
||||
callback(null, []);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('LocalStorage', () => {
|
|||
expect(storage).toBeDefined();
|
||||
});
|
||||
|
||||
describe('LocalStorage::addPackage', () => {
|
||||
describe('LocalStorage::preparePackage', () => {
|
||||
test('should add a package', (done) => {
|
||||
const metadata = JSON.parse(readMetadata());
|
||||
// $FlowFixMe
|
||||
|
@ -69,30 +69,7 @@ describe('LocalStorage', () => {
|
|||
test('should fails on add a package', (done) => {
|
||||
const metadata = JSON.parse(readMetadata());
|
||||
|
||||
storage.addPackage(pkgName, metadata, (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(409);
|
||||
// expect(err.status).toMatch(/this package is already present/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LocalStorage::addVersion', () => {
|
||||
test('should add new version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
|
||||
storage.addVersion(pkgName, '1.0.1', metadata, '', (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails on add a duplicated version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
|
||||
storage.addVersion(pkgName, '1.0.1', metadata, '', (err, data) => {
|
||||
storage.addPackage(pkgName, metadata, (err) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(409);
|
||||
expect(err.message).toMatch(/this package is already present/);
|
||||
|
@ -100,230 +77,253 @@ describe('LocalStorage', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('should add new second version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
describe('LocalStorage::addVersion', () => {
|
||||
test('should add new version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
|
||||
storage.addVersion(pkgName, '1.0.2', metadata, 'beta', (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LocalStorage::updateVersions', () => {
|
||||
test('should update versions from origin', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
||||
|
||||
storage.updateVersions(pkgName, metadata, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data.versions['1.0.3']).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LocalStorage::changePackage', () => {
|
||||
test('should unpublish a version', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-unpublish'));
|
||||
const rev: string = metadata['_rev'];
|
||||
|
||||
storage.changePackage(pkgName, metadata, rev, (err) => {
|
||||
expect(err).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('LocalStorage::addTarball', () => {
|
||||
|
||||
test('should add a new tarball', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName);
|
||||
|
||||
stream.on('error', function(err) {
|
||||
expect(err).toBeNull();
|
||||
done();
|
||||
});
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
storage.addVersion(pkgName, '1.0.1', metadata, '', (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
test('should fails on add a duplicated version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
|
||||
test('should add a new second tarball', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName2);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).toBeNull();
|
||||
done();
|
||||
});
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
storage.addVersion(pkgName, '1.0.1', metadata, '', (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(409);
|
||||
expect(err.message).toMatch(/this package is already present/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
test('should add new second version without tag', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-add-version'));
|
||||
|
||||
test('should fails on add a duplicated new tarball ', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(409);
|
||||
expect(err.message).toMatch(/this package is already present/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on add a new tarball on missing package', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball('unexsiting-package', tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on use invalid package name on add a new tarball', (done) => {
|
||||
const stream = storage.addTarball(pkgName, `${pkgName}-fails-add-tarball-1.0.4.tgz`);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(422);
|
||||
expect(err.message).toMatch(/refusing to accept zero-length file/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on abort on add a new tarball', (done) => {
|
||||
const stream = storage.addTarball('package.json', `${pkgName}-fails-add-tarball-1.0.4.tgz`);
|
||||
stream.abort();
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(403);
|
||||
expect(err.message).toMatch(/can't use this filename/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('LocalStorage::removeTarball', () => {
|
||||
|
||||
test('should remove a tarball', (done) => {
|
||||
storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => {
|
||||
expect(err).toBeNull();
|
||||
expect(pkg).toBeUndefined();
|
||||
done();
|
||||
storage.addVersion(pkgName, '1.0.2', metadata, 'beta', (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should remove a tarball that does not exist', (done) => {
|
||||
storage.removeTarball(pkgName, tarballName2, 'rev', (err) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such file available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('LocalStorage::updateVersions', () => {
|
||||
test('should update versions from origin', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
||||
|
||||
describe('LocalStorage::getTarball', () => {
|
||||
test('should get a existing tarball', (done) => {
|
||||
const stream = storage.getTarball(pkgName, tarballName);
|
||||
stream.on('content-length', function(contentLength) {
|
||||
expect(contentLength).toBe(279);
|
||||
done();
|
||||
});
|
||||
stream.on('open', function() {
|
||||
done();
|
||||
storage.updateVersions(pkgName, metadata, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data.versions['1.0.3']).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails on get a tarball that does not exist', (done) => {
|
||||
const stream = storage.getTarball('fake', tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such file available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('LocalStorage::changePackage', () => {
|
||||
test('should unpublish a version', (done) => {
|
||||
const metadata = JSON.parse(readMetadata('metadata-unpublish'));
|
||||
const rev: string = metadata['_rev'];
|
||||
|
||||
describe('LocalStorage::search', () => {
|
||||
test('should find a tarball', (done) => {
|
||||
const stream = storage.search('99999');
|
||||
|
||||
stream.on('data', function each(pkg) {
|
||||
expect(pkg.name).toEqual(pkgName);
|
||||
});
|
||||
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
done();
|
||||
storage.changePackage(pkgName, metadata, rev, (err) => {
|
||||
expect(err).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
describe('LocalStorage::addTarball', () => {
|
||||
|
||||
describe('LocalStorage::removePackage', () => {
|
||||
test('should remove completely package', (done) => {
|
||||
storage.removePackage(pkgName, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
test('should add a new tarball', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName);
|
||||
|
||||
stream.on('error', function(err) {
|
||||
expect(err).toBeNull();
|
||||
done();
|
||||
});
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should add a new second tarball', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName2);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).toBeNull();
|
||||
done();
|
||||
});
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on add a duplicated new tarball ', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball(pkgName, tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(409);
|
||||
expect(err.message).toMatch(/this package is already present/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on add a new tarball on missing package', (done) => {
|
||||
const tarballData = JSON.parse(readMetadata('addTarball'));
|
||||
const stream = storage.addTarball('unexsiting-package', tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('success', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
stream.end(new Buffer(tarballData.data, 'base64'));
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on use invalid package name on add a new tarball', (done) => {
|
||||
const stream = storage.addTarball(pkgName, `${pkgName}-fails-add-tarball-1.0.4.tgz`);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(422);
|
||||
expect(err.message).toMatch(/refusing to accept zero-length file/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.done();
|
||||
});
|
||||
|
||||
test('should fails on abort on add a new tarball', (done) => {
|
||||
const stream = storage.addTarball('package.json', `${pkgName}-fails-add-tarball-1.0.4.tgz`);
|
||||
stream.abort();
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(403);
|
||||
expect(err.message).toMatch(/can't use this filename/);
|
||||
done();
|
||||
});
|
||||
|
||||
stream.done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should remove completely @scoped package', (done) => {
|
||||
storage.removePackage(pkgNameScoped, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
describe('LocalStorage::removeTarball', () => {
|
||||
|
||||
test('should remove a tarball', (done) => {
|
||||
storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => {
|
||||
expect(err).toBeNull();
|
||||
expect(pkg).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should remove a tarball that does not exist', (done) => {
|
||||
storage.removeTarball(pkgName, tarballName2, 'rev', (err) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such file available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails with package not found', (done) => {
|
||||
const pkgName: string = 'npm_test_fake';
|
||||
storage.removePackage(pkgName, (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
describe('LocalStorage::getTarball', () => {
|
||||
test('should get a existing tarball', (done) => {
|
||||
const stream = storage.getTarball(pkgName, tarballName);
|
||||
stream.on('content-length', function(contentLength) {
|
||||
expect(contentLength).toBe(279);
|
||||
done();
|
||||
});
|
||||
stream.on('open', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails on get a tarball that does not exist', (done) => {
|
||||
const stream = storage.getTarball('fake', tarballName);
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.message).toMatch(/no such file available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails with @scoped package not found', (done) => {
|
||||
storage.removePackage(pkgNameScoped, (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
describe('LocalStorage::search', () => {
|
||||
test('should find a tarball', (done) => {
|
||||
const stream = storage.search('99999');
|
||||
|
||||
stream.on('data', function each(pkg) {
|
||||
expect(pkg.name).toEqual(pkgName);
|
||||
});
|
||||
|
||||
stream.on('error', function(err) {
|
||||
expect(err).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('LocalStorage::removePackage', () => {
|
||||
test('should remove completely package', (done) => {
|
||||
storage.removePackage(pkgName, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should remove completely @scoped package', (done) => {
|
||||
storage.removePackage(pkgNameScoped, (err, data) => {
|
||||
expect(err).toBeNull();
|
||||
expect(data).toBeUndefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails with package not found', (done) => {
|
||||
const pkgName: string = 'npm_test_fake';
|
||||
storage.removePackage(pkgName, (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should fails with @scoped package not found', (done) => {
|
||||
storage.removePackage(pkgNameScoped, (err, data) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue