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

Function runTests

test/parallel/test-fastutf8stream-reopen.js:30–188  ·  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 stream = new Utf8Stream({ dest, sync });
35
36 assert.ok(stream.write('hello world\n'));
37 assert.ok(stream.write('something else\n'));
38
39 const after = dest + '-moved';
40
41 stream.once('drain', common.mustCall(() => {
42 renameSync(dest, after);
43 stream.reopen();
44
45 stream.once('ready', common.mustCall(() => {
46 assert.ok(stream.write('after reopen\n'));
47
48 stream.once('drain', common.mustCall(() => {
49 readFile(after, 'utf8', common.mustSucceed((data) => {
50 assert.strictEqual(data, 'hello world\nsomething else\n');
51 readFile(dest, 'utf8', common.mustSucceed((data) => {
52 assert.strictEqual(data, 'after reopen\n');
53 stream.end();
54 }));
55 }));
56 }));
57 }));
58 }));
59 }
60
61 {
62 const dest = getTempFile();
63 const stream = new Utf8Stream({ dest, sync });
64
65 assert.ok(stream.write('hello world\n'));
66 assert.ok(stream.write('something else\n'));
67
68 stream.reopen();
69 stream.end();
70
71 stream.on('close', common.mustCall());
72 }
73
74 {
75 const dest = getTempFile();
76 const stream = new Utf8Stream({ dest, minLength: 0, sync });
77
78 assert.ok(stream.write('hello world\n'));
79 assert.ok(stream.write('something else\n'));
80
81 const after = dest + '-new';
82
83 stream.once('drain', common.mustCall(() => {
84 stream.reopen(after);
85 assert.strictEqual(stream.file, after);
86
87 stream.once('ready', common.mustCall(() => {

Callers 1

Calls 13

writeMethod · 0.95
reopenMethod · 0.95
endMethod · 0.95
getTempFileFunction · 0.70
readFileFunction · 0.70
openSyncFunction · 0.70
cbFunction · 0.70
openFunction · 0.70
renameSyncFunction · 0.50
setTimeoutFunction · 0.50
okMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…