Skip to content

Commit 4104e68

Browse files
committed
Add typed wrapper for skippedUploadMacro
1 parent 231b974 commit 4104e68

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/init-action-post-helper.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ test.serial(
796796
},
797797
);
798798

799-
const skippedUploadTest = test.macro({
799+
const skippedUploadMacro = test.macro({
800800
exec: async (
801801
t: ExecutionContext<unknown>,
802802
config: Partial<configUtils.Config>,
@@ -823,9 +823,22 @@ const skippedUploadTest = test.macro({
823823
`tryUploadSarifIfRunFailed - skips upload ${providedTitle}`,
824824
});
825825

826-
test.serial(
826+
/**
827+
* Wraps `skippedUploadMacro` to improve type checking.
828+
*
829+
* When the macro is invoked directly, e.g. via `test.serial(macro, ...)`, the
830+
* precise types of the arguments are erased.
831+
*/
832+
function testSkippedUpload(
833+
title: string,
834+
config: Partial<configUtils.Config>,
835+
expectedSkippedReason: string,
836+
) {
837+
test.serial(title, skippedUploadMacro, config, expectedSkippedReason);
838+
}
839+
840+
testSkippedUpload(
827841
"without CodeQL command",
828-
skippedUploadTest,
829842
// No codeQLCmd
830843
{
831844
analysisKinds: [AnalysisKind.RiskAssessment],
@@ -834,9 +847,8 @@ test.serial(
834847
"CodeQL command not found",
835848
);
836849

837-
test.serial(
850+
testSkippedUpload(
838851
"if no language is configured",
839-
skippedUploadTest,
840852
// No explicit language configuration
841853
{
842854
analysisKinds: [AnalysisKind.RiskAssessment],
@@ -845,9 +857,8 @@ test.serial(
845857
"Unexpectedly, the configuration is not for a single language.",
846858
);
847859

848-
test.serial(
860+
testSkippedUpload(
849861
"if multiple languages is configured",
850-
skippedUploadTest,
851862
// Multiple explicit languages configured
852863
{
853864
analysisKinds: [AnalysisKind.RiskAssessment],

0 commit comments

Comments
 (0)