Skip to content

Commit

Permalink
Merge pull request #1251 from zowe/next-daemon-enable
Browse files Browse the repository at this point in the history
Next daemon enable for new pipeline
  • Loading branch information
gejohnston authored Jan 11, 2022
2 parents 2333808 + e33e3e5 commit 6a52f06
Show file tree
Hide file tree
Showing 42 changed files with 9,557 additions and 8,965 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To try out early access features, install the "next" release of Zowe CLI (`npm i
For documentation about these features, see these files:

- [Using Global Profile Configuration](https://github.com/zowe/zowe-cli/blob/next/docs/Early%20Access%20-%20Using%20Global%20Profile%20Configuration.md)
- [Using Daemon Mode with "zowex"](https://github.com/zowe/zowe-cli/blob/next/zowex/design.md)
- [Daemon Mode Design Overview](https://github.com/zowe/zowe-cli/blob/next/zowex/design.md)

## Documentation

Expand Down
61 changes: 61 additions & 0 deletions __mocks__/child_process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

'use strict';

const child_process: any = jest.genMockFromModule("child_process");

const useRealFunction: string = "useRealFunction";
let execSyncOutput: string = useRealFunction;
const spawnSyncOutput = {
"stdout": useRealFunction
};

// tests can set their own output value for execSync
function setExecSyncOutput(outputVal: string) {
execSyncOutput = outputVal;
}

// tests can set their own output value for spawnSync
function setSpawnSyncOutput(outputVal: string) {
spawnSyncOutput.stdout = outputVal;
}
// Mock function to use for child_process.execSync
function execSyncMock(cmd: string, options: Object) {
if (execSyncOutput === useRealFunction) {
// run the real execSync
const execSyncReal = require.requireActual("child_process").execSync;
return execSyncReal(cmd, options);
} else {
// return the output that the test set with setExecSyncOutput().
return execSyncOutput;
}
}

// Mock function to use for child_process.spawnSync
function spawnSyncMock(cmd: string, args: [string], options: Object) {
if (spawnSyncOutput.stdout === useRealFunction) {
// run the real spawnSync
const spawnSyncReal = require.requireActual("child_process").spawnSync;
return spawnSyncReal(cmd, args, options);
} else {
// return the output that the test set with setSpawnSyncOutput().
return spawnSyncOutput;
}
}

child_process.setExecSyncOutput = setExecSyncOutput;
child_process.execSync = execSyncMock;

child_process.setSpawnSyncOutput = setSpawnSyncOutput;
child_process.spawnSync = spawnSyncMock;

module.exports = child_process;
Loading

0 comments on commit 6a52f06

Please sign in to comment.