1 | 'use strict'
|
2 |
|
3 | const test = require('tap').test
|
4 | const { spawn } = require('child_process')
|
5 | const endpoint = require('endpoint')
|
6 | const rimraf = require('rimraf')
|
7 | const ClinicDoctor = require('../index.js')
|
8 |
|
9 | test('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 |
|
18 | test('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 | })
|