fix removeTmp

master
Gregory Scheerlinck 9 years ago
parent 1673174a85
commit 653c71e01b

@ -43,11 +43,11 @@ function tmpSave(roff) {
});
}
function removeTmp(tmp) {
return fsUnlink(tmp).then(function deleteTmp() {
function removeTmp() {
return fsUnlink(tmpFile).then(function deleteTmp() {
return 'done';
}).catch(function catchUnlink(err) {
console.log('Could not delete the temporary file at ' + tmp);
console.log('Could not delete the temporary file at ' + tmpFile);
console.log('Error: ', + err);
});
}

@ -8,6 +8,7 @@ var fileio = require('../lib/fileio');
var Promise = require('bluebird');
var fsReadFile = Promise.promisify(require('fs').readFile);
var fsUnlink = Promise.promisify(require('fs').unlink);
var fsWriteFile = Promise.promisify(require('fs').writeFile);
var path = require('path');
describe('methods', function() {
@ -95,3 +96,20 @@ describe('tmpSave', function() {
});
});
});
describe('removeTmp', function() {
var tmp = path.resolve('./tmp/tmpfile');
before(function(done) {
fsWriteFile(tmp, 'hello world').then(function() {
done();
});
});
it('deletes the temporary file', function(done) {
fileio.removeTmp().then(function(result) {
expect(result).to.equal('done');
done();
});
});
});

Loading…
Cancel
Save