mirror of
https://github.com/Minionguyjpro/Inno-Setup-Action
synced 2026-02-18 17:41:18 +01:00
Update main.test.js
This commit is contained in:
@@ -1,38 +1,15 @@
|
|||||||
// main.test.js
|
// main.test.js
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { exec } = require("child_process"); // Add this line to import exec
|
const { main } = require("../src/main"); // Adjust the path accordingly
|
||||||
|
|
||||||
function main() {
|
jest.mock("@actions/core");
|
||||||
const workspacePath = process.env.GITHUB_WORKSPACE;
|
|
||||||
|
|
||||||
const options = core.getInput("options");
|
describe("Inno Setup Action", () => {
|
||||||
const path = core.getInput("path");
|
it("should execute Inno Setup command on Windows with existing workspace", () => {
|
||||||
|
process.platform = "win32";
|
||||||
let repoError;
|
main();
|
||||||
let platformError;
|
expect(core.getInput).toHaveBeenCalledTimes(2);
|
||||||
|
expect(fs.existsSync).toHaveBeenCalled();
|
||||||
if (process.platform === "win32") {
|
});
|
||||||
if (fs.existsSync(workspacePath) && fs.readdirSync(workspacePath).length > 0) {
|
});
|
||||||
exec(`"%PROGRAMFILES(X86)%\\Inno Setup 6\\iscc.exe" ${options} "${workspacePath}\\${path}"`, { stdio: "ignore" }, function (execError, stdout, stderr) {
|
|
||||||
console.log(stdout);
|
|
||||||
|
|
||||||
if (execError) {
|
|
||||||
repoError = { code: execError.code || 1 };
|
|
||||||
core.setFailed(stderr);
|
|
||||||
process.exit(repoError.code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
repoError = { code: 1 };
|
|
||||||
core.setFailed("The repository was not cloned. Please specify the actions/checkout action before this step.");
|
|
||||||
process.exit(repoError.code);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
platformError = { code: 1 };
|
|
||||||
core.setFailed("This action is only supported on Windows!");
|
|
||||||
process.exit(platformError.code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { main };
|
|
||||||
|
|||||||
Reference in New Issue
Block a user