1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add test for case if loading credentials from storage has an error

This commit is contained in:
hbeeken 2014-07-28 14:29:35 +01:00
parent 536a0c9142
commit 132dcdeb43

View File

@ -26,7 +26,6 @@ describe('Credentials', function() {
var storage = {
getCredentials: function() {
console.log("ONE");
return when.promise(function(resolve,reject) {
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);
});
});
})