Skip to content

Commit

Permalink
Tidy up properly between file node tests
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jan 14, 2018
1 parent 14429d2 commit 4453a51
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/nodes/core/storage/50-file_spec.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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}];
Expand All @@ -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); }
Expand All @@ -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() {
Expand All @@ -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}];
Expand All @@ -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); }
Expand All @@ -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}];
Expand Down

0 comments on commit 4453a51

Please sign in to comment.