mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Move sessionStorageModule into main storageModule
Fixes #586 - add get/saveSessions to main storage module - handle storage modules without those functions - store .session file in userDir
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
var should = require("should");
|
||||
var storage = require("../../../red/storage/index");
|
||||
|
||||
describe("red/storage/index", function() {
|
||||
|
||||
@@ -23,7 +24,6 @@ describe("red/storage/index", function() {
|
||||
storageModule : "thisaintloading"
|
||||
};
|
||||
|
||||
var storage = require("../../../red/storage/index");
|
||||
storage.init(wrongModule).then( function() {
|
||||
var one = 1;
|
||||
var zero = 0;
|
||||
@@ -50,17 +50,18 @@ describe("red/storage/index", function() {
|
||||
storageModule : moduleWithBooleanSettingInit
|
||||
};
|
||||
|
||||
var storage = require("../../../red/storage/index");
|
||||
storage.init(setsBooleanModule);
|
||||
initSetsMeToTrue.should.be.true;
|
||||
done();
|
||||
});
|
||||
|
||||
it('respects storage interface', function(done) {
|
||||
it('respects storage interface', function() {
|
||||
var calledFlagGetFlows = false;
|
||||
var calledFlagGetCredentials = false;
|
||||
var calledFlagGetAllFlows = false;
|
||||
var calledInit = false;
|
||||
var calledFlagGetSettings = false;
|
||||
var calledFlagGetSessions = false;
|
||||
|
||||
var interfaceCheckerModule = {
|
||||
init : function (settings) {
|
||||
@@ -79,6 +80,18 @@ describe("red/storage/index", function() {
|
||||
saveCredentials : function(credentials) {
|
||||
credentials.should.be.true;
|
||||
},
|
||||
getSettings : function() {
|
||||
calledFlagGetSettings = true;
|
||||
},
|
||||
saveSettings : function(settings) {
|
||||
settings.should.be.true;
|
||||
},
|
||||
getSessions : function() {
|
||||
calledFlagGetSessions = true;
|
||||
},
|
||||
saveSessions : function(sessions) {
|
||||
sessions.should.be.true;
|
||||
},
|
||||
getAllFlows : function() {
|
||||
calledFlagGetAllFlows = true;
|
||||
},
|
||||
@@ -102,15 +115,18 @@ describe("red/storage/index", function() {
|
||||
};
|
||||
|
||||
var moduleToLoad = {
|
||||
storageModule : interfaceCheckerModule
|
||||
storageModule : interfaceCheckerModule
|
||||
};
|
||||
var storage = require("../../../red/storage/index");
|
||||
|
||||
storage.init(moduleToLoad);
|
||||
storage.getFlows();
|
||||
storage.saveFlows(true);
|
||||
storage.getCredentials();
|
||||
storage.saveCredentials(true);
|
||||
storage.getSettings();
|
||||
storage.saveSettings(true);
|
||||
storage.getSessions();
|
||||
storage.saveSessions(true);
|
||||
storage.getAllFlows();
|
||||
storage.getFlow("name");
|
||||
storage.saveFlow("name", true);
|
||||
@@ -121,8 +137,38 @@ describe("red/storage/index", function() {
|
||||
calledFlagGetFlows.should.be.true;
|
||||
calledFlagGetCredentials.should.be.true;
|
||||
calledFlagGetAllFlows.should.be.true;
|
||||
});
|
||||
|
||||
describe('handles missing settings/sessions interface', function() {
|
||||
before(function() {
|
||||
var interfaceCheckerModule = {
|
||||
init : function () {}
|
||||
};
|
||||
storage.init({storageModule: interfaceCheckerModule});
|
||||
});
|
||||
|
||||
done();
|
||||
it('defaults missing getSettings',function(done) {
|
||||
storage.getSettings().then(function(settings) {
|
||||
should.not.exist(settings);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('defaults missing saveSettings',function(done) {
|
||||
storage.saveSettings({}).then(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('defaults missing getSessions',function(done) {
|
||||
storage.getSessions().then(function(settings) {
|
||||
should.not.exist(settings);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('defaults missing saveSessions',function(done) {
|
||||
storage.saveSessions({}).then(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user