UNPKG

898 BJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const { spawn } = require('child_process')
5const endpoint = require('endpoint')
6const rimraf = require('rimraf')
7const ClinicDoctor = require('../index.js')
8
9test('cmd - collect - cluster required but not used is ok', function (t) {
10 const doctor = new ClinicDoctor({})
11 doctor.collect([process.execPath, '-e', 'require("cluster")'], (err, result) => {
12 t.ifError(err, 'should not crash when cluster is required but not used')
13 rimraf.sync(result)
14 t.end()
15 })
16})
17
18test('cmd - collect - using cluster causes error', function (t) {
19 const proc = spawn(process.execPath, [
20 require.resolve('./cmd-no-cluster.script.js')
21 ], { stdio: 'pipe' })
22
23 proc.stderr.pipe(endpoint((err, buf) => {
24 t.ifError(err)
25 t.ok(buf.toString('utf8').includes('does not support clustering'), 'should crash once cluster is used')
26 t.end()
27 }))
28})