diff --git a/src/lib.test.ts b/src/lib.test.ts index 65129d2..db8e3f4 100644 --- a/src/lib.test.ts +++ b/src/lib.test.ts @@ -8,7 +8,7 @@ describe("exportSecrets()", () => { getInput: vi.fn().mockImplementation((s: string) => { switch (s) { case "secrets": - return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D"}'; + return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}'; case "downcase-tf-var": return ""; case "downcase-tf-token": @@ -59,19 +59,24 @@ describe("exportSecrets()", () => { "TF_VAR_KEY_D", "VALUE_D", ); + expect(coreMock.exportVariable).toHaveBeenNthCalledWith( + 5, + "TF_TOKEN_KEY_E", + "VALUE_E", + ); }); }); - describe("success_downcase-tf-token", () => { + describe("success_downcase-tf-var", () => { const coreMock = { getInput: vi.fn().mockImplementation((s: string) => { switch (s) { case "secrets": - return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_TOKEN_EXAMPLE_COM":"xyz"}'; + return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}'; case "downcase-tf-var": - return ""; - case "downcase-tf-token": return "true"; + case "downcase-tf-token": + return ""; default: return ""; } @@ -115,22 +120,27 @@ describe("exportSecrets()", () => { ); expect(coreMock.exportVariable).toHaveBeenNthCalledWith( 4, - "TF_TOKEN_example_com", - "xyz", + "TF_VAR_key_d", + "VALUE_D", + ); + expect(coreMock.exportVariable).toHaveBeenNthCalledWith( + 5, + "TF_TOKEN_KEY_E", + "VALUE_E", ); }); }); - describe("success_downcase-tf-var", () => { + describe("success_downcase-tf-token", () => { const coreMock = { getInput: vi.fn().mockImplementation((s: string) => { switch (s) { case "secrets": - return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D"}'; + return '{"KEY_A":"VALUE_A","KEY_B":"VALUE_B","KEY_C":"VALUE_C","TF_VAR_KEY_D":"VALUE_D","TF_TOKEN_KEY_E":"VALUE_E"}'; case "downcase-tf-var": - return "true"; - case "downcase-tf-token": return ""; + case "downcase-tf-token": + return "true"; default: return ""; } @@ -174,9 +184,14 @@ describe("exportSecrets()", () => { ); expect(coreMock.exportVariable).toHaveBeenNthCalledWith( 4, - "TF_VAR_key_d", + "TF_VAR_KEY_D", "VALUE_D", ); + expect(coreMock.exportVariable).toHaveBeenNthCalledWith( + 5, + "TF_TOKEN_key_e", + "VALUE_E", + ); }); }); diff --git a/src/lib.ts b/src/lib.ts index 74462ca..dd611c9 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -22,7 +22,7 @@ export function exportSecrets(core: ActionsCore) { `TF_VAR_${key.replace(/^TF_VAR_/, "").toLowerCase()}`, value, ); - return; + continue; } if (downcaseTfToken && key.startsWith("TF_TOKEN_")) { @@ -30,7 +30,7 @@ export function exportSecrets(core: ActionsCore) { `TF_TOKEN_${key.replace(/^TF_TOKEN_/, "").toLowerCase()}`, value, ); - return; + continue; } core.exportVariable(key, value);