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

Function runTests

test/parallel/test-fastutf8stream-flush-mocks.js:30–102  ·  view source on GitHub ↗
(sync)

Source from the content-addressed store, hash-verified

28runTests(true);
29
30function runTests(sync) {
31
32 {
33 const dest = getTempFile();
34 const fd = openSync(dest, 'w');
35
36 const fsOverride = {
37 fsync: common.mustNotCall(),
38 fsyncSync: common.mustCall(() => fsyncSync(fd)),
39 };
40 if (sync) {
41 fsOverride.writeSync = common.mustCall((...args) => writeSync(...args));
42 fsOverride.write = common.mustNotCall();
43 } else {
44 fsOverride.write = common.mustCall((...args) => write(...args));
45 fsOverride.writeSync = common.mustNotCall();
46 }
47
48 const stream = new Utf8Stream({
49 fd,
50 sync,
51 fsync: true,
52 minLength: 4096,
53 fs: fsOverride,
54 });
55
56 stream.on('ready', common.mustCall(() => {
57 assert.ok(stream.write('hello world\n'));
58
59 stream.flush(common.mustSucceed(() => stream.end()));
60 }));
61 }
62
63 {
64 const dest = getTempFile();
65 const fd = openSync(dest, 'w');
66
67 const testError = new Error('fsync failed');
68 testError.code = 'ETEST';
69
70 const fsOverride = {
71 fsync: common.mustCall((fd, cb) => {
72 process.nextTick(() => cb(testError));
73 }, 2),
74 };
75
76 if (sync) {
77 fsOverride.writeSync = common.mustCall((...args) => {
78 return writeSync(...args);
79 });
80 } else {
81 fsOverride.write = common.mustCall((...args) => {
82 return write(...args);
83 });
84 }
85
86 const stream = new Utf8Stream({
87 fd,

Calls 11

writeMethod · 0.95
flushMethod · 0.95
endMethod · 0.95
getTempFileFunction · 0.70
openSyncFunction · 0.70
fsyncSyncFunction · 0.70
writeSyncFunction · 0.70
writeFunction · 0.70
cbFunction · 0.70
onMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…