(sync)
| 26 | runTests(true); |
| 27 | |
| 28 | function runTests(sync) { |
| 29 | { |
| 30 | const dest = getTempFile(); |
| 31 | writeFileSync(dest, 'hello world\n'); |
| 32 | const stream = new Utf8Stream({ dest, append: false, sync }); |
| 33 | |
| 34 | stream.on('ready', common.mustCall(() => { |
| 35 | assert.ok(stream.write('something else\n')); |
| 36 | stream.flush(); |
| 37 | |
| 38 | stream.on('drain', common.mustCall(() => { |
| 39 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 40 | assert.strictEqual(data, 'something else\n'); |
| 41 | stream.end(); |
| 42 | })); |
| 43 | })); |
| 44 | })); |
| 45 | } |
| 46 | |
| 47 | { |
| 48 | const dest = join(getTempFile(), 'out.log'); |
| 49 | const stream = new Utf8Stream({ dest, mkdir: true, sync }); |
| 50 | |
| 51 | stream.on('ready', common.mustCall(() => { |
| 52 | assert.ok(stream.write('hello world\n')); |
| 53 | stream.flush(); |
| 54 | |
| 55 | stream.on('drain', common.mustCall(() => { |
| 56 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 57 | assert.strictEqual(data, 'hello world\n'); |
| 58 | stream.end(); |
| 59 | })); |
| 60 | })); |
| 61 | })); |
| 62 | } |
| 63 | |
| 64 | { |
| 65 | const dest = getTempFile(); |
| 66 | const fd = openSync(dest, 'w'); |
| 67 | const stream = new Utf8Stream({ fd, minLength: 4096, sync }); |
| 68 | |
| 69 | stream.on('ready', common.mustCall(() => { |
| 70 | assert.ok(stream.write('hello world\n')); |
| 71 | assert.ok(stream.write('something else\n')); |
| 72 | stream.flush(); |
| 73 | |
| 74 | stream.on('drain', common.mustCall(() => { |
| 75 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 76 | assert.strictEqual(data, 'hello world\nsomething else\n'); |
| 77 | stream.end(); |
| 78 | })); |
| 79 | })); |
| 80 | })); |
| 81 | } |
| 82 | |
| 83 | { |
| 84 | const dest = getTempFile(); |
| 85 | const fd = openSync(dest, 'w'); |
no test coverage detected
searching dependent graphs…