Add node installation from other than public site

This commit is contained in:
KAZUHIRO ITO
2019-11-11 18:25:36 +09:00
parent e94634544c
commit ff96773295
7 changed files with 60 additions and 16 deletions

View File

@@ -227,7 +227,7 @@ describe("api/admin/nodes", function() {
});
request(app)
.post('/nodes')
.send({module: 'foo',version:"1.2.3"})
.send({module: 'foo',version:"1.2.3",url:"https://example/foo-1.2.3.tgz"})
.expect(200)
.end(function(err,res) {
if (err) {
@@ -238,6 +238,7 @@ describe("api/admin/nodes", function() {
res.body.nodes[0].should.have.property("id","123");
opts.should.have.property("module","foo");
opts.should.have.property("version","1.2.3");
opts.should.have.property("url","https://example/foo-1.2.3.tgz");
done();
});
});
@@ -256,7 +257,7 @@ describe("api/admin/nodes", function() {
});
request(app)
.post('/nodes')
.send({module: 'foo',version:"1.2.3"})
.send({module: 'foo',version:"1.2.3",url:"https://example/foo-1.2.3.tgz"})
.expect(400)
.end(function(err,res) {
if (err) {

View File

@@ -121,6 +121,17 @@ describe('nodes/registry/installer', function() {
done();
});
});
it("rejects when update requested to existing version and url", function(done) {
sinon.stub(typeRegistry,"getModuleInfo", function() {
return {
version: "0.1.1"
}
});
installer.installModule("this_wont_exist","0.1.1","https://example/foo-0.1.1.tgz").catch(function(err) {
err.code.should.be.eql('module_already_loaded');
done();
});
});
it("rejects with generic error", function(done) {
var res = {
code: 1,
@@ -201,6 +212,29 @@ describe('nodes/registry/installer', function() {
done(err);
});
});
it("succeeds when url is valid node-red module", function(done) {
var nodeInfo = {nodes:{module:"foo",types:["a"]}};
var res = {
code: 0,
stdout:"",
stderr:""
}
var p = Promise.resolve(res);
p.catch((err)=>{});
initInstaller(p)
var addModule = sinon.stub(registry,"addModule",function(md) {
return when.resolve(nodeInfo);
});
installer.installModule("this_wont_exist",null,"https://example/foo-0.1.1.tgz").then(function(info) {
info.should.eql(nodeInfo);
done();
}).catch(function(err) {
done(err);
});
});
});
describe("uninstalls module", function() {