1 | ;
|
2 | // *****************************************************************************
|
3 | // Copyright (C) 2021 Ericsson and others.
|
4 | //
|
5 | // This program and the accompanying materials are made available under the
|
6 | // terms of the Eclipse Public License v. 2.0 which is available at
|
7 | // http://www.eclipse.org/legal/epl-2.0.
|
8 | //
|
9 | // This Source Code may also be made available under the following Secondary
|
10 | // Licenses when the conditions for such availability set forth in the Eclipse
|
11 | // Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
12 | // with the GNU Classpath Exception which is available at
|
13 | // https://www.gnu.org/software/classpath/license.html.
|
14 | //
|
15 | // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
16 | // *****************************************************************************
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const chai_1 = require("chai");
|
19 | const inversify_1 = require("inversify");
|
20 | const process_utils_1 = require("./process-utils");
|
21 | /** PPID, PID */
|
22 | const mockPsOutput = `\
|
23 | 5 6
|
24 | 40 7
|
25 | 1 2
|
26 | 1 3
|
27 | 2 40
|
28 | 2 5
|
29 | 0 1
|
30 | `;
|
31 | describe('ProcessUtils', () => {
|
32 | let coreProcessManager;
|
33 | beforeEach(() => {
|
34 | const container = new inversify_1.Container();
|
35 | container.bind(process_utils_1.ProcessUtils).toSelf().inSingletonScope();
|
36 | coreProcessManager = container.get(process_utils_1.ProcessUtils);
|
37 | });
|
38 | it('ProcessUtils#unixGetChildrenRecursive', () => {
|
39 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
40 | coreProcessManager['spawnSync'] = () => ({ stdout: mockPsOutput });
|
41 | const pids = coreProcessManager['unixGetChildrenRecursive'](2);
|
42 | (0, chai_1.expect)(Array.from(pids)).members([40, 5, 6, 7]);
|
43 | });
|
44 | });
|
45 | //# sourceMappingURL=process-utils.spec.js.map |
\ | No newline at end of file |