Skip to content

Commit cd00cbb

Browse files
committed
Add typed wrapper for injectedConfigMacro
1 parent 51cc915 commit cd00cbb

1 file changed

Lines changed: 33 additions & 24 deletions

File tree

src/codeql.test.ts

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -590,19 +590,38 @@ const injectedConfigMacro = test.macro({
590590
`databaseInitCluster() injected config: ${providedTitle}`,
591591
});
592592

593-
test.serial(
593+
/**
594+
* Wraps `injectedConfigMacro` to improve type checking.
595+
*
596+
* When the macro is invoked directly, e.g. via `test.serial(macro, ...)`, the
597+
* precise types of the arguments are erased.
598+
*/
599+
function testInjectedConfig(
600+
title: string,
601+
augmentationProperties: AugmentationProperties,
602+
configOverride: Partial<Config>,
603+
expectedConfig: any,
604+
) {
605+
test.serial(
606+
title,
607+
injectedConfigMacro,
608+
augmentationProperties,
609+
configOverride,
610+
expectedConfig,
611+
);
612+
}
613+
614+
testInjectedConfig(
594615
"basic",
595-
injectedConfigMacro,
596616
{
597617
...defaultAugmentationProperties,
598618
},
599619
{},
600620
{},
601621
);
602622

603-
test.serial(
623+
testInjectedConfig(
604624
"injected packs from input",
605-
injectedConfigMacro,
606625
{
607626
...defaultAugmentationProperties,
608627
packsInput: ["xxx", "yyy"],
@@ -613,9 +632,8 @@ test.serial(
613632
},
614633
);
615634

616-
test.serial(
635+
testInjectedConfig(
617636
"injected packs from input with existing packs combines",
618-
injectedConfigMacro,
619637
{
620638
...defaultAugmentationProperties,
621639
packsInputCombines: true,
@@ -635,9 +653,8 @@ test.serial(
635653
},
636654
);
637655

638-
test.serial(
656+
testInjectedConfig(
639657
"injected packs from input with existing packs overrides",
640-
injectedConfigMacro,
641658
{
642659
...defaultAugmentationProperties,
643660
packsInput: ["xxx", "yyy"],
@@ -655,9 +672,8 @@ test.serial(
655672
);
656673

657674
// similar, but with queries
658-
test.serial(
675+
testInjectedConfig(
659676
"injected queries from input",
660-
injectedConfigMacro,
661677
{
662678
...defaultAugmentationProperties,
663679
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
@@ -675,9 +691,8 @@ test.serial(
675691
},
676692
);
677693

678-
test.serial(
694+
testInjectedConfig(
679695
"injected queries from input overrides",
680-
injectedConfigMacro,
681696
{
682697
...defaultAugmentationProperties,
683698
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
@@ -699,9 +714,8 @@ test.serial(
699714
},
700715
);
701716

702-
test.serial(
717+
testInjectedConfig(
703718
"injected queries from input combines",
704-
injectedConfigMacro,
705719
{
706720
...defaultAugmentationProperties,
707721
queriesInputCombines: true,
@@ -727,9 +741,8 @@ test.serial(
727741
},
728742
);
729743

730-
test.serial(
744+
testInjectedConfig(
731745
"injected queries from input combines 2",
732-
injectedConfigMacro,
733746
{
734747
...defaultAugmentationProperties,
735748
queriesInputCombines: true,
@@ -749,9 +762,8 @@ test.serial(
749762
},
750763
);
751764

752-
test.serial(
765+
testInjectedConfig(
753766
"injected queries and packs, but empty",
754-
injectedConfigMacro,
755767
{
756768
...defaultAugmentationProperties,
757769
queriesInputCombines: true,
@@ -768,9 +780,8 @@ test.serial(
768780
{},
769781
);
770782

771-
test.serial(
783+
testInjectedConfig(
772784
"repo property queries have the highest precedence",
773-
injectedConfigMacro,
774785
{
775786
...defaultAugmentationProperties,
776787
queriesInputCombines: true,
@@ -790,9 +801,8 @@ test.serial(
790801
},
791802
);
792803

793-
test.serial(
804+
testInjectedConfig(
794805
"repo property queries combines with queries input",
795-
injectedConfigMacro,
796806
{
797807
...defaultAugmentationProperties,
798808
queriesInputCombines: false,
@@ -817,9 +827,8 @@ test.serial(
817827
},
818828
);
819829

820-
test.serial(
830+
testInjectedConfig(
821831
"repo property queries combines everything else",
822-
injectedConfigMacro,
823832
{
824833
...defaultAugmentationProperties,
825834
queriesInputCombines: true,

0 commit comments

Comments
 (0)