Skip to content

Commit e9930e6

Browse files
authoredDec 1, 2021
Improve syncfalse test (#1253)
1 parent ec9b0b5 commit e9930e6

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed
 

‎test/transport/syncfalse.test.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
'use strict'
22

3+
const os = require('os')
34
const pino = require('../..')
45
const { join } = require('path')
56
const { test } = require('tap')
7+
const { readFile } = require('fs').promises
8+
const { watchFileCreated } = require('../helper')
69

7-
test('thread-stream async flush', async () => {
10+
const { pid } = process
11+
const hostname = os.hostname()
12+
13+
test('thread-stream async flush', async ({ same }) => {
14+
const destination = join(
15+
os.tmpdir(),
16+
'_' + Math.random().toString(36).substr(2, 9)
17+
)
818
const transport = pino.transport({
9-
target: join(__dirname, '..', 'fixtures', 'console-transport.js')
19+
target: join(__dirname, '..', 'fixtures', 'to-file-transport.js'),
20+
options: { destination }
1021
})
1122
const instance = pino(transport)
1223
instance.info('hello')
1324
instance.flush()
25+
await watchFileCreated(destination)
26+
const result = JSON.parse(await readFile(destination))
27+
delete result.time
28+
same(result, {
29+
pid,
30+
hostname,
31+
level: 30,
32+
msg: 'hello'
33+
})
1434
})

0 commit comments

Comments
 (0)