e715b04a11
When proxy environment variables (https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY) are detected and NODE_USE_ENV_PROXY is not already set to "1", the action spawns a child process with NODE_USE_ENV_PROXY=1 to enable Node.js native proxy support. - Add lib/run-with-proxy.js shared utility for both main.js and post.js - Update main.js and post.js to use runWithProxy() wrapper - Add tests for proxy spawning, child error handling, and already-enabled path - 100% code coverage maintained Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
31 lines
814 B
JavaScript
31 lines
814 B
JavaScript
// Verify that `main.js` rejects when the child process exits with a non-zero code.
|
|
import assert from "node:assert";
|
|
import { mock } from "node:test";
|
|
|
|
mock.module("node:child_process", {
|
|
namedExports: {
|
|
spawn() {
|
|
return {
|
|
on(event, callback) {
|
|
if (event === "exit") callback(1);
|
|
},
|
|
};
|
|
},
|
|
},
|
|
});
|
|
|
|
process.env.GITHUB_REPOSITORY = "actions/create-github-app-token";
|
|
process.env.GITHUB_REPOSITORY_OWNER = "actions";
|
|
process.env.https_proxy = "http://proxy.example.com";
|
|
delete process.env.NODE_USE_ENV_PROXY;
|
|
|
|
const { default: runPromise } = await import("../main.js");
|
|
|
|
await assert.rejects(runPromise, {
|
|
message: "Child process exited with code 1",
|
|
});
|
|
assert.equal(process.exitCode, 1, "process exit code is 1");
|
|
|
|
// Reset for other tests
|
|
process.exitCode = 0;
|