Skip to content

Commit 231b974

Browse files
committed
Add typed wrapper for toolcacheInputFallbackMacro
1 parent cd00cbb commit 231b974

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

src/setup-codeql.test.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,31 @@ const toolcacheInputFallbackMacro = test.macro({
533533
`getCodeQLSource falls back to downloading the CLI if ${providedTitle}`,
534534
});
535535

536-
test.serial(
536+
/**
537+
* Wraps `toolcacheInputFallbackMacro` to improve type checking.
538+
*
539+
* When the macro is invoked directly, e.g. via `test.serial(macro, ...)`, the
540+
* precise types of the arguments are erased.
541+
*/
542+
function testToolcacheInputFallback(
543+
title: string,
544+
featureList: Feature[],
545+
environment: Record<string, string>,
546+
testVersions: string[],
547+
expectedMessages: string[],
548+
) {
549+
test.serial(
550+
title,
551+
toolcacheInputFallbackMacro,
552+
featureList,
553+
environment,
554+
testVersions,
555+
expectedMessages,
556+
);
557+
}
558+
559+
testToolcacheInputFallback(
537560
"the toolcache doesn't have a CodeQL CLI when tools == toolcache",
538-
toolcacheInputFallbackMacro,
539561
[Feature.AllowToolcacheInput],
540562
{ GITHUB_EVENT_NAME: "dynamic" },
541563
[],
@@ -545,9 +567,8 @@ test.serial(
545567
],
546568
);
547569

548-
test.serial(
570+
testToolcacheInputFallback(
549571
"the workflow trigger is not `dynamic`",
550-
toolcacheInputFallbackMacro,
551572
[Feature.AllowToolcacheInput],
552573
{ GITHUB_EVENT_NAME: "pull_request" },
553574
[],
@@ -556,9 +577,8 @@ test.serial(
556577
],
557578
);
558579

559-
test.serial(
580+
testToolcacheInputFallback(
560581
"the feature flag is not enabled",
561-
toolcacheInputFallbackMacro,
562582
[],
563583
{ GITHUB_EVENT_NAME: "dynamic" },
564584
[],

0 commit comments

Comments
 (0)