MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-fs-open-mode-mask.js:16–37  ·  view source on GitHub ↗
(mode, asString)

Source from the content-addressed store, hash-verified

14tmpdir.refresh();
15
16function test(mode, asString) {
17 const suffix = asString ? 'str' : 'num';
18 const input = asString ?
19 (mode | maskToIgnore).toString(8) : (mode | maskToIgnore);
20
21 {
22 const file = tmpdir.resolve(`openSync-${suffix}.txt`);
23 const fd = fs.openSync(file, 'w+', input);
24 assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode);
25 fs.closeSync(fd);
26 assert.strictEqual(fs.statSync(file).mode & 0o777, mode);
27 }
28
29 {
30 const file = tmpdir.resolve(`open-${suffix}.txt`);
31 fs.open(file, 'w+', input, common.mustSucceed((fd) => {
32 assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode);
33 fs.closeSync(fd);
34 assert.strictEqual(fs.statSync(file).mode & 0o777, mode);
35 }));
36 }
37}
38
39test(mode, true);
40test(mode, false);

Callers 1

Calls 7

fstatSyncMethod · 0.80
openMethod · 0.65
toStringMethod · 0.45
resolveMethod · 0.45
openSyncMethod · 0.45
closeSyncMethod · 0.45
statSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…