mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge master to 0.18
This commit is contained in:
@@ -26,11 +26,11 @@ var registry = require("../../../../red/runtime/nodes/registry");
|
||||
|
||||
describe("red/nodes/index", function() {
|
||||
before(function() {
|
||||
sinon.stub(flows,"startFlows");
|
||||
sinon.stub(index,"startFlows");
|
||||
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
|
||||
});
|
||||
after(function() {
|
||||
flows.startFlows.restore();
|
||||
index.startFlows.restore();
|
||||
delete process.env.NODE_RED_HOME;
|
||||
});
|
||||
|
||||
|
@@ -17,8 +17,10 @@
|
||||
var should = require("should");
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
var sinon = require('sinon');
|
||||
|
||||
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||
var log = require("../../../../red/runtime/log");
|
||||
|
||||
describe('LocalFileSystem', function() {
|
||||
var userDir = path.join(__dirname,".testUserHome");
|
||||
@@ -279,6 +281,45 @@ describe('LocalFileSystem', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should fsync the flows file',function(done) {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
sinon.spy(fs,"fsync");
|
||||
localfilesystem.saveFlows(testFlow).then(function() {
|
||||
fs.fsync.callCount.should.eql(1);
|
||||
fs.fsync.restore();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should log fsync errors and continue',function(done) {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
sinon.stub(fs,"fsync", function(fd, cb) {
|
||||
cb(new Error());
|
||||
});
|
||||
sinon.spy(log,"warn");
|
||||
localfilesystem.saveFlows(testFlow).then(function() {
|
||||
log.warn.callCount.should.eql(1);
|
||||
log.warn.restore();
|
||||
fs.fsync.callCount.should.eql(1);
|
||||
fs.fsync.restore();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should backup the flows file', function(done) {
|
||||
var defaultFlowFile = 'flows_'+require('os').hostname()+'.json';
|
||||
var defaultFlowFilePath = path.join(userDir,defaultFlowFile);
|
||||
|
Reference in New Issue
Block a user