Skip to content

Commit

Permalink
debugging ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm committed Sep 19, 2021
1 parent a21c9f8 commit dd0f15c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/end-to-end/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ const setTimeout = promisify(global.setTimeout)

t.test('must log to a custom collection', async () => {
const customCollection = 'custom-collection'
const process = spawn('node', [
const childProcess = spawn('node', [
'../../pino-mongodb.js',
mongoUrl,
'-c',
customCollection
], {
cwd: __dirname,
killSignal: 'SIGINT',
stdio: ['pipe', null, null]
stdio: ['pipe', 'inherit', 'inherit']
})

const client = new MongoClient(mongoUrl)
Expand All @@ -30,14 +29,14 @@ t.test('must log to a custom collection', async () => {

const rowsBefore = await collection.countDocuments()

process.stdin.write('hello pino-mongo 1\n')
process.stdin.write(`${JSON.stringify({ hello: 'pino' })}\n`)
process.stdin.write('hello pino-mongo 2\n')
childProcess.stdin.write('hello pino-mongo 1\n')
childProcess.stdin.write(`${JSON.stringify({ hello: 'pino' })}\n`)
childProcess.stdin.write('hello pino-mongo 2\n')

await setTimeout(1000)

process.kill('SIGINT')
await once(process, 'close')
childProcess.kill('SIGTERM')
await once(childProcess, 'close')

const rowsAfter = await collection.countDocuments()
t.equal(rowsAfter, rowsBefore + 3, 'logged 3 rows')
Expand Down

0 comments on commit dd0f15c

Please sign in to comment.