From 4453a512112931670fe741e85eef4cdb119b9916 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 14 Jan 2018 01:06:55 +0000 Subject: [PATCH] Tidy up properly between file node tests --- test/nodes/core/storage/50-file_spec.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/nodes/core/storage/50-file_spec.js b/test/nodes/core/storage/50-file_spec.js index a558beb4f..d3ee3fcb4 100644 --- a/test/nodes/core/storage/50-file_spec.js +++ b/test/nodes/core/storage/50-file_spec.js @@ -36,6 +36,7 @@ describe('file Nodes', function() { }); afterEach(function(done) { + fs.removeSync(path.join(resourcesDir,"file-out-node")); helper.unload().then(function() { //fs.unlinkSync(fileToTest); helper.stopServer(done); @@ -368,7 +369,7 @@ describe('file Nodes', function() { it('should fail to create a new directory if not asked to do so (append)', function(done) { // Stub file write so we can make writes fail - var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt"); + var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt"); //var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false}]; @@ -380,7 +381,9 @@ describe('file Nodes', function() { return evt[0].type == "file"; }); //console.log(logEvents); - logEvents.should.have.length(0); + logEvents.should.have.length(1); + logEvents[0][0].should.have.a.property('msg'); + logEvents[0][0].msg.toString().should.startWith("file.errors.appendfail"); done(); } catch(e) { done(e); } @@ -392,7 +395,7 @@ describe('file Nodes', function() { it('should try to create a new directory if asked to do so (append)', function(done) { // Stub file write so we can make writes fail - var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt"); + var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt"); var spy = sinon.stub(fs, "ensureDir", function(arg1,arg2,arg3,arg4) { arg2(null); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false, "createDir":true}]; helper.load(fileNode, flow, function() { @@ -415,7 +418,7 @@ describe('file Nodes', function() { it('should fail to create a new directory if not asked to do so (overwrite)', function(done) { // Stub file write so we can make writes fail - var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt"); + var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt"); //var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":false, "overwriteFile":true}]; @@ -427,7 +430,9 @@ describe('file Nodes', function() { return evt[0].type == "file"; }); //console.log(logEvents); - logEvents.should.have.length(0); + logEvents.should.have.length(1); + logEvents[0][0].should.have.a.property('msg'); + logEvents[0][0].msg.toString().should.startWith("file.errors.writefail"); done(); } catch(e) { done(e); } @@ -439,7 +444,7 @@ describe('file Nodes', function() { it('should try to create a new directory if asked to do so (overwrite)', function(done) { // Stub file write so we can make writes fail - var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt"); + var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt"); var spy = sinon.stub(fs, "ensureDir", function(arg1,arg2,arg3,arg4) { arg2(null); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":true, "createDir":true}];