Skip to content

Commit

Permalink
test: add flag scenario in test-fs-write-file-sync
Browse files Browse the repository at this point in the history
fs.writeFileSync takes flag param to define the file opening
semantics. Add a scenario that covers flags as well.

PR-URL: #24766
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
gireeshpunathil authored and BridgeAR committed Dec 5, 2018
1 parent 7c70b61 commit 9572008
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/parallel/test-fs-write-file-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,12 @@ function closeSync() {
openCount--;
return fs._closeSync.apply(fs, arguments);
}

// Test writeFileSync with flags
const file4 = path.join(tmpdir.path, 'testWriteFileSyncFlags.txt');

fs.writeFileSync(file4, 'hello ', { encoding: 'utf8', flag: 'a' });
fs.writeFileSync(file4, 'world!', { encoding: 'utf8', flag: 'a' });

content = fs.readFileSync(file4, { encoding: 'utf8' });
assert.strictEqual(content, 'hello world!');

0 comments on commit 9572008

Please sign in to comment.