1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02: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:
Nick O'Leary 2014-07-29 11:24:18 +01:00
commit ac1e750f14

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);
});
});
})