mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch '0.18' into projects
This commit is contained in:
@@ -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('storage/localfilesystem', function() {
|
||||
var mockRuntime = {
|
||||
@@ -285,6 +287,45 @@ describe('storage/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