From dc2ced8385fe206c30e6accdd2d900759080cadf Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 10 Oct 2025 14:20:51 +0100 Subject: [PATCH] Add tests for scenarios where the feature is unavailable --- src/setup-codeql.test.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/setup-codeql.test.ts b/src/setup-codeql.test.ts index d02bf59e6..3046b6ff5 100644 --- a/src/setup-codeql.test.ts +++ b/src/setup-codeql.test.ts @@ -325,7 +325,7 @@ test("getCodeQLSource correctly returns latest version from toolcache when tools typeof msg.message === "string" && msg.message.includes(expectedMessage), ), - `Expected '${expectedMessage}' in the logger output, but didn't find it.`, + `Expected '${expectedMessage}' in the logger output, but didn't find it in:\n ${loggedMessages.map((m) => ` - '${m.message}'`).join("\n")}`, ); } }); @@ -381,7 +381,7 @@ const toolcacheInputFallbackMacro = test.macro({ typeof msg.message === "string" && msg.message.includes(expectedMessage), ), - `Expected '${expectedMessage}' in the logger output, but didn't find it.`, + `Expected '${expectedMessage}' in the logger output, but didn't find it in:\n ${loggedMessages.map((m) => ` - '${m.message}'`).join("\n")}`, ); } }); @@ -402,6 +402,26 @@ test( ], ); +test( + "the workflow trigger is not `dynamic`", + toolcacheInputFallbackMacro, + [Feature.AllowToolcacheInput], + { GITHUB_EVENT_NAME: "pull_request" }, + [], + [ + `Ignoring 'tools: toolcache' because the workflow was not triggered dynamically.`, + ], +); + +test( + "the feature flag is not enabled", + toolcacheInputFallbackMacro, + [], + { GITHUB_EVENT_NAME: "dynamic" }, + [], + [`Ignoring 'tools: toolcache' because the feature is not enabled.`], +); + test('tryGetTagNameFromUrl extracts the right tag name for a repo name containing "codeql-bundle"', (t) => { t.is( setupCodeql.tryGetTagNameFromUrl(