diff options
author | Rich Trott <rtrott@gmail.com> | 2017-12-24 22:38:11 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-01-31 22:11:07 -0800 |
commit | bf6ce47259ebfe9f6349c223cc1735726aee062d (patch) | |
tree | 2f40f8e9618a253862cf1f0953992c8c16b56772 /test/parallel/test-fs-append-file-sync.js | |
parent | 6035beea93e16f6d923201a33a541f6d724f00d6 (diff) | |
download | android-node-v8-bf6ce47259ebfe9f6349c223cc1735726aee062d.tar.gz android-node-v8-bf6ce47259ebfe9f6349c223cc1735726aee062d.tar.bz2 android-node-v8-bf6ce47259ebfe9f6349c223cc1735726aee062d.zip |
test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir).
PR-URL: https://github.com/nodejs/node/pull/17856
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-append-file-sync.js')
-rw-r--r-- | test/parallel/test-fs-append-file-sync.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/parallel/test-fs-append-file-sync.js b/test/parallel/test-fs-append-file-sync.js index 31e95c2e36..b836d81bd5 100644 --- a/test/parallel/test-fs-append-file-sync.js +++ b/test/parallel/test-fs-append-file-sync.js @@ -36,10 +36,11 @@ const data = '南越国是前203年至前111年存在于岭南地区的一个国 '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; -common.refreshTmpDir(); +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); // test that empty file will be created and have content added -const filename = join(common.tmpDir, 'append-sync.txt'); +const filename = join(tmpdir.path, 'append-sync.txt'); fs.appendFileSync(filename, data); @@ -48,7 +49,7 @@ const fileData = fs.readFileSync(filename); assert.strictEqual(Buffer.byteLength(data), fileData.length); // test that appends data to a non empty file -const filename2 = join(common.tmpDir, 'append-sync2.txt'); +const filename2 = join(tmpdir.path, 'append-sync2.txt'); fs.writeFileSync(filename2, currentFileData); fs.appendFileSync(filename2, data); @@ -59,7 +60,7 @@ assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, fileData2.length); // test that appendFileSync accepts buffers -const filename3 = join(common.tmpDir, 'append-sync3.txt'); +const filename3 = join(tmpdir.path, 'append-sync3.txt'); fs.writeFileSync(filename3, currentFileData); const buf = Buffer.from(data, 'utf8'); @@ -70,7 +71,7 @@ const fileData3 = fs.readFileSync(filename3); assert.strictEqual(buf.length + currentFileData.length, fileData3.length); // test that appendFile accepts numbers. -const filename4 = join(common.tmpDir, 'append-sync4.txt'); +const filename4 = join(tmpdir.path, 'append-sync4.txt'); fs.writeFileSync(filename4, currentFileData, { mode: m }); fs.appendFileSync(filename4, num, { mode: m }); @@ -87,7 +88,7 @@ assert.strictEqual(Buffer.byteLength(String(num)) + currentFileData.length, fileData4.length); // test that appendFile accepts file descriptors -const filename5 = join(common.tmpDir, 'append-sync5.txt'); +const filename5 = join(tmpdir.path, 'append-sync5.txt'); fs.writeFileSync(filename5, currentFileData); const filename5fd = fs.openSync(filename5, 'a+', 0o600); |