test: Put fs write test files in tmp
This prevents fixture litter when these tests fail.
This commit is contained in:
parent
f0f87d8afb
commit
55aa973bee
@ -36,17 +36,18 @@ var data = '南越国是前203年至前111年存在于岭南地区的一个国
|
||||
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
|
||||
|
||||
// test that empty file will be created and have content added
|
||||
var filename = join(common.fixturesDir, 'append-sync.txt');
|
||||
var filename = join(common.tmpDir, 'append-sync.txt');
|
||||
|
||||
common.error('appending to ' + filename);
|
||||
fs.appendFileSync(filename, data);
|
||||
|
||||
var fileData = fs.readFileSync(filename);
|
||||
console.error('filedata is a ' + typeof fileData);
|
||||
|
||||
assert.equal(Buffer.byteLength(data), fileData.length);
|
||||
|
||||
// test that appends data to a non empty file
|
||||
var filename2 = join(common.fixturesDir, 'append-sync2.txt');
|
||||
var filename2 = join(common.tmpDir, 'append-sync2.txt');
|
||||
fs.writeFileSync(filename2, currentFileData);
|
||||
|
||||
common.error('appending to ' + filename2);
|
||||
@ -58,7 +59,7 @@ assert.equal(Buffer.byteLength(data) + currentFileData.length,
|
||||
fileData2.length);
|
||||
|
||||
// test that appendFileSync accepts buffers
|
||||
var filename3 = join(common.fixturesDir, 'append-sync3.txt');
|
||||
var filename3 = join(common.tmpDir, 'append-sync3.txt');
|
||||
fs.writeFileSync(filename3, currentFileData);
|
||||
|
||||
common.error('appending to ' + filename3);
|
||||
@ -71,7 +72,7 @@ var fileData3 = fs.readFileSync(filename3);
|
||||
assert.equal(buf.length + currentFileData.length, fileData3.length);
|
||||
|
||||
// test that appendFile accepts numbers.
|
||||
var filename4 = join(common.fixturesDir, 'append-sync4.txt');
|
||||
var filename4 = join(common.tmpDir, 'append-sync4.txt');
|
||||
fs.writeFileSync(filename4, currentFileData);
|
||||
|
||||
common.error('appending to ' + filename4);
|
||||
|
@ -24,7 +24,7 @@ var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var join = require('path').join;
|
||||
|
||||
var filename = join(common.fixturesDir, 'append.txt');
|
||||
var filename = join(common.tmpDir, 'append.txt');
|
||||
|
||||
common.error('appending to ' + filename);
|
||||
|
||||
@ -57,7 +57,7 @@ fs.appendFile(filename, s, function(e) {
|
||||
});
|
||||
|
||||
// test that appends data to a non empty file
|
||||
var filename2 = join(common.fixturesDir, 'append2.txt');
|
||||
var filename2 = join(common.tmpDir, 'append2.txt');
|
||||
fs.writeFileSync(filename2, currentFileData);
|
||||
|
||||
fs.appendFile(filename2, s, function(e) {
|
||||
@ -75,7 +75,7 @@ fs.appendFile(filename2, s, function(e) {
|
||||
});
|
||||
|
||||
// test that appendFile accepts buffers
|
||||
var filename3 = join(common.fixturesDir, 'append3.txt');
|
||||
var filename3 = join(common.tmpDir, 'append3.txt');
|
||||
fs.writeFileSync(filename3, currentFileData);
|
||||
|
||||
var buf = new Buffer(s, 'utf8');
|
||||
@ -96,7 +96,7 @@ fs.appendFile(filename3, buf, function(e) {
|
||||
});
|
||||
|
||||
// test that appendFile accepts numbers.
|
||||
var filename4 = join(common.fixturesDir, 'append4.txt');
|
||||
var filename4 = join(common.tmpDir, 'append4.txt');
|
||||
fs.writeFileSync(filename4, currentFileData);
|
||||
|
||||
common.error('appending to ' + filename4);
|
||||
|
@ -24,7 +24,7 @@ var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var join = require('path').join;
|
||||
|
||||
var filename = join(common.fixturesDir, 'test.txt');
|
||||
var filename = join(common.tmpDir, 'test.txt');
|
||||
|
||||
common.error('writing to ' + filename);
|
||||
|
||||
@ -54,7 +54,7 @@ fs.writeFile(filename, s, function(e) {
|
||||
});
|
||||
|
||||
// test that writeFile accepts buffers
|
||||
var filename2 = join(common.fixturesDir, 'test2.txt');
|
||||
var filename2 = join(common.tmpDir, 'test2.txt');
|
||||
var buf = new Buffer(s, 'utf8');
|
||||
common.error('writing to ' + filename2);
|
||||
|
||||
@ -73,7 +73,7 @@ fs.writeFile(filename2, buf, function(e) {
|
||||
});
|
||||
|
||||
// test that writeFile accepts numbers.
|
||||
var filename3 = join(common.fixturesDir, 'test3.txt');
|
||||
var filename3 = join(common.tmpDir, 'test3.txt');
|
||||
common.error('writing to ' + filename3);
|
||||
|
||||
fs.writeFile(filename3, n, function(e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user