From 95720089d54fe5d11d4b7a9094cac1518cf3bec7 Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Sat, 1 Dec 2018 12:52:25 +0530 Subject: [PATCH] test: add flag scenario in test-fs-write-file-sync fs.writeFileSync takes flag param to define the file opening semantics. Add a scenario that covers flags as well. PR-URL: https://github.com/nodejs/node/pull/24766 Reviewed-By: Richard Lau Reviewed-By: Anto Aravinth Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig --- test/parallel/test-fs-write-file-sync.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-fs-write-file-sync.js b/test/parallel/test-fs-write-file-sync.js index 2964ac368b5de4..cb0f16f370f43c 100644 --- a/test/parallel/test-fs-write-file-sync.js +++ b/test/parallel/test-fs-write-file-sync.js @@ -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!');