From a5ad13f1cbb3e464cebb2cdb7052c728af60062b 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!');