Skip to content

Commit 9572008

Browse files
gireeshpunathilBridgeAR
authored andcommitted
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: #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>
1 parent 7c70b61 commit 9572008

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/parallel/test-fs-write-file-sync.js

+9
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,12 @@ function closeSync() {
9696
openCount--;
9797
return fs._closeSync.apply(fs, arguments);
9898
}
99+
100+
// Test writeFileSync with flags
101+
const file4 = path.join(tmpdir.path, 'testWriteFileSyncFlags.txt');
102+
103+
fs.writeFileSync(file4, 'hello ', { encoding: 'utf8', flag: 'a' });
104+
fs.writeFileSync(file4, 'world!', { encoding: 'utf8', flag: 'a' });
105+
106+
content = fs.readFileSync(file4, { encoding: 'utf8' });
107+
assert.strictEqual(content, 'hello world!');

0 commit comments

Comments
 (0)