Skip to content

Commit 58b00a7

Browse files
Mossakaclaude
andcommitted
fix: use template literals in tests so RUNNER_TEMP is evaluated at runtime
Tests were using regular double-quoted strings like "...${process.env.RUNNER_TEMP}/gh-aw..." which compared against the literal text "${process.env.RUNNER_TEMP}" instead of the resolved path. Changed to backtick template literals so the env var is evaluated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b92e3ba commit 58b00a7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

actions/setup/js/redact_secrets.test.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("redact_secrets.cjs", () => {
4646
describe("main function integration", () => {
4747
(it("should scan for built-in patterns even when GH_AW_SECRET_NAMES is not set", async () => {
4848
(await eval(`(async () => { ${redactScript}; await main(); })()`),
49-
expect(mockCore.info).toHaveBeenCalledWith("Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories"),
49+
expect(mockCore.info).toHaveBeenCalledWith(`Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories`),
5050
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Scanning for built-in credential patterns")));
5151
}),
5252
it("should redact secrets from files in /tmp using exact matching", async () => {
@@ -57,7 +57,7 @@ describe("redact_secrets.cjs", () => {
5757
await eval(`(async () => { ${modifiedScript}; await main(); })()`);
5858
const redactedContent = fs.readFileSync(testFile, "utf8");
5959
(expect(redactedContent).toBe("Secret: ***REDACTED*** and another ***REDACTED***"),
60-
expect(mockCore.info).toHaveBeenCalledWith("Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories"),
60+
expect(mockCore.info).toHaveBeenCalledWith(`Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories`),
6161
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Secret redaction complete")));
6262
}),
6363
it("should handle multiple file types", async () => {
@@ -123,7 +123,7 @@ describe("redact_secrets.cjs", () => {
123123
(fs.writeFileSync(testFile, "No secrets here"), (process.env.GH_AW_SECRET_NAMES = "EMPTY_SECRET"), (process.env.SECRET_EMPTY_SECRET = ""));
124124
const modifiedScript = redactScript.replace('findFiles("/tmp/gh-aw", targetExtensions)', `findFiles("${tempDir.replace(/\\/g, "\\\\")}", targetExtensions)`);
125125
(await eval(`(async () => { ${modifiedScript}; await main(); })()`),
126-
expect(mockCore.info).toHaveBeenCalledWith("Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories"),
126+
expect(mockCore.info).toHaveBeenCalledWith(`Starting secret redaction in /tmp/gh-aw and ${process.env.RUNNER_TEMP}/gh-aw directories`),
127127
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("no secrets found")));
128128
}),
129129
it("should handle new file extensions (.md, .mdx, .yml, .jsonl)", async () => {

actions/setup/js/safe_outputs_mcp_server_defaults.test.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ const canWriteDefault = canWriteToDefaultPath();
7272
setTimeout(() => {
7373
(child.kill(),
7474
clearTimeout(timeout),
75-
expect(stderr).toContain("GH_AW_SAFE_OUTPUTS not set, using default: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl"),
76-
expect(stderr).toContain("Reading config from file: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json"),
75+
expect(stderr).toContain(`GH_AW_SAFE_OUTPUTS not set, using default: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/outputs.jsonl`),
76+
expect(stderr).toContain(`Reading config from file: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json`),
7777
resolve());
7878
}, 2e3));
7979
});
@@ -102,7 +102,7 @@ const canWriteDefault = canWriteToDefaultPath();
102102
(child.kill(),
103103
clearTimeout(timeout),
104104
fs.existsSync(defaultConfigFile) && fs.unlinkSync(defaultConfigFile),
105-
expect(stderr).toContain("Reading config from file: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json"),
105+
expect(stderr).toContain(`Reading config from file: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json`),
106106
expect(stderr).toContain("Successfully parsed config from file with 2 configuration keys"),
107107
expect(stderr).toContain("Final processed config:"),
108108
expect(stderr).toContain("create_issue"),
@@ -132,7 +132,7 @@ const canWriteDefault = canWriteToDefaultPath();
132132
setTimeout(() => {
133133
(child.kill(),
134134
clearTimeout(timeout),
135-
expect(stderr).toContain("Config file does not exist at: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json"),
135+
expect(stderr).toContain(`Config file does not exist at: ${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json`),
136136
expect(stderr).toContain("Using minimal default configuration"),
137137
expect(stderr).toContain("Final processed config: {}"),
138138
resolve());

0 commit comments

Comments
 (0)