mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 11:36:53 +00:00
Merge pull request #304 from hbeeken/test-credentials
Add test for case if loading credentials from storage has an error
This commit is contained in:
commit
ac1e750f14
@ -26,7 +26,6 @@ describe('Credentials', function() {
|
|||||||
|
|
||||||
var storage = {
|
var storage = {
|
||||||
getCredentials: function() {
|
getCredentials: function() {
|
||||||
console.log("ONE");
|
|
||||||
return when.promise(function(resolve,reject) {
|
return when.promise(function(resolve,reject) {
|
||||||
resolve({"a":{"b":1,"c":2}});
|
resolve({"a":{"b":1,"c":2}});
|
||||||
});
|
});
|
||||||
@ -114,6 +113,34 @@ describe('Credentials', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handle error loading from storage', function(done) {
|
||||||
|
var util = require("util");
|
||||||
|
var storage = {
|
||||||
|
getCredentials: function() {
|
||||||
|
return when.promise(function(resolve,reject) {
|
||||||
|
reject("test forcing failure");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
saveCredentials: function(creds) {
|
||||||
|
return when(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var logmsg = 'no errors yet';
|
||||||
|
sinon.stub(util, 'log', function(msg) {
|
||||||
|
logmsg = msg;
|
||||||
|
});
|
||||||
|
|
||||||
|
credentials.init(storage);
|
||||||
|
credentials.load().then(function() {
|
||||||
|
should.equal('[red] Error loading credentials : test forcing failure', logmsg);
|
||||||
|
util.log.restore();
|
||||||
|
done();
|
||||||
|
}).otherwise(function(err){
|
||||||
|
util.log.restore();
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user