Add node module update api and expose in palette editor

This commit is contained in:
Nick O'Leary
2017-01-21 23:46:44 +00:00
parent 0720128bd4
commit e27f5d0460
10 changed files with 210 additions and 50 deletions

View File

@@ -46,6 +46,9 @@ describe('nodes/registry/installer', function() {
if (registry.getModuleInfo.restore) {
registry.getModuleInfo.restore();
}
if (typeRegistry.getModuleInfo.restore) {
typeRegistry.getModuleInfo.restore();
}
if (require('fs').statSync.restore) {
require('fs').statSync.restore();
@@ -64,6 +67,32 @@ describe('nodes/registry/installer', function() {
done();
});
});
it("rejects when npm does not find specified version", function(done) {
sinon.stub(child_process,"execFile",function(cmd,args,opt,cb) {
cb(new Error(),""," version not found: this_wont_exist@0.1.2");
});
sinon.stub(typeRegistry,"getModuleInfo", function() {
return {
version: "0.1.1"
}
});
installer.installModule("this_wont_exist","0.1.2").otherwise(function(err) {
err.code.should.be.eql(404);
done();
});
});
it("rejects when update requested to existing version", function(done) {
sinon.stub(typeRegistry,"getModuleInfo", function() {
return {
version: "0.1.1"
}
});
installer.installModule("this_wont_exist","0.1.1").otherwise(function(err) {
err.code.should.be.eql('module_already_loaded');
done();
});
});
it("rejects with generic error", function(done) {
sinon.stub(child_process,"execFile",function(cmd,args,opt,cb) {
cb(new Error("test_error"),"","");