Skip to content

Commit 7230d69

Browse files
committed
Use defaultAugmentationProperties in tests
Using defaultAugmentationProperties to generated expected test output eliminates the need to change individual tests when we add a new field to AugmentationProperties.
1 parent 466d6ce commit 7230d69

File tree

2 files changed

+24
-37
lines changed

2 files changed

+24
-37
lines changed

src/codeql.test.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import * as actionsUtil from "./actions-util";
1414
import { GitHubApiDetails } from "./api-client";
1515
import { CliError } from "./cli-errors";
1616
import * as codeql from "./codeql";
17-
import { AugmentationProperties, Config } from "./config-utils";
17+
import {
18+
AugmentationProperties,
19+
Config,
20+
defaultAugmentationProperties,
21+
} from "./config-utils";
1822
import * as defaults from "./defaults.json";
1923
import { DocUrl } from "./doc-url";
2024
import { FeatureEnablement } from "./feature-flags";
@@ -537,8 +541,7 @@ test(
537541
"basic",
538542
injectedConfigMacro,
539543
{
540-
queriesInputCombines: false,
541-
packsInputCombines: false,
544+
...defaultAugmentationProperties,
542545
},
543546
{},
544547
{},
@@ -548,8 +551,7 @@ test(
548551
"injected packs from input",
549552
injectedConfigMacro,
550553
{
551-
queriesInputCombines: false,
552-
packsInputCombines: false,
554+
...defaultAugmentationProperties,
553555
packsInput: ["xxx", "yyy"],
554556
},
555557
{},
@@ -562,7 +564,7 @@ test(
562564
"injected packs from input with existing packs combines",
563565
injectedConfigMacro,
564566
{
565-
queriesInputCombines: false,
567+
...defaultAugmentationProperties,
566568
packsInputCombines: true,
567569
packsInput: ["xxx", "yyy"],
568570
},
@@ -584,8 +586,7 @@ test(
584586
"injected packs from input with existing packs overrides",
585587
injectedConfigMacro,
586588
{
587-
queriesInputCombines: false,
588-
packsInputCombines: false,
589+
...defaultAugmentationProperties,
589590
packsInput: ["xxx", "yyy"],
590591
},
591592
{
@@ -605,8 +606,7 @@ test(
605606
"injected queries from input",
606607
injectedConfigMacro,
607608
{
608-
queriesInputCombines: false,
609-
packsInputCombines: false,
609+
...defaultAugmentationProperties,
610610
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
611611
},
612612
{},
@@ -626,8 +626,7 @@ test(
626626
"injected queries from input overrides",
627627
injectedConfigMacro,
628628
{
629-
queriesInputCombines: false,
630-
packsInputCombines: false,
629+
...defaultAugmentationProperties,
631630
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
632631
},
633632
{
@@ -651,8 +650,8 @@ test(
651650
"injected queries from input combines",
652651
injectedConfigMacro,
653652
{
653+
...defaultAugmentationProperties,
654654
queriesInputCombines: true,
655-
packsInputCombines: false,
656655
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
657656
},
658657
{
@@ -679,6 +678,7 @@ test(
679678
"injected queries from input combines 2",
680679
injectedConfigMacro,
681680
{
681+
...defaultAugmentationProperties,
682682
queriesInputCombines: true,
683683
packsInputCombines: true,
684684
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
@@ -700,6 +700,7 @@ test(
700700
"injected queries and packs, but empty",
701701
injectedConfigMacro,
702702
{
703+
...defaultAugmentationProperties,
703704
queriesInputCombines: true,
704705
packsInputCombines: true,
705706
queriesInput: [],

src/config-utils.test.ts

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -830,12 +830,8 @@ test(
830830
undefined,
831831
[Language.javascript],
832832
{
833-
queriesInputCombines: false,
834-
queriesInput: undefined,
835-
packsInputCombines: false,
836-
packsInput: undefined,
837-
defaultQueryFilters: [],
838-
} as configUtils.AugmentationProperties,
833+
...configUtils.defaultAugmentationProperties,
834+
},
839835
);
840836

841837
test(
@@ -845,12 +841,9 @@ test(
845841
" a, b , c, d",
846842
[Language.javascript],
847843
{
848-
queriesInputCombines: false,
844+
...configUtils.defaultAugmentationProperties,
849845
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
850-
packsInputCombines: false,
851-
packsInput: undefined,
852-
defaultQueryFilters: [],
853-
} as configUtils.AugmentationProperties,
846+
},
854847
);
855848

856849
test(
@@ -860,12 +853,10 @@ test(
860853
" + a, b , c, d ",
861854
[Language.javascript],
862855
{
856+
...configUtils.defaultAugmentationProperties,
863857
queriesInputCombines: true,
864858
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
865-
packsInputCombines: false,
866-
packsInput: undefined,
867-
defaultQueryFilters: [],
868-
} as configUtils.AugmentationProperties,
859+
},
869860
);
870861

871862
test(
@@ -875,12 +866,9 @@ test(
875866
undefined,
876867
[Language.javascript],
877868
{
878-
queriesInputCombines: false,
879-
queriesInput: undefined,
880-
packsInputCombines: false,
869+
...configUtils.defaultAugmentationProperties,
881870
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
882-
defaultQueryFilters: [],
883-
} as configUtils.AugmentationProperties,
871+
},
884872
);
885873

886874
test(
@@ -890,12 +878,10 @@ test(
890878
undefined,
891879
[Language.javascript],
892880
{
893-
queriesInputCombines: false,
894-
queriesInput: undefined,
881+
...configUtils.defaultAugmentationProperties,
895882
packsInputCombines: true,
896883
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
897-
defaultQueryFilters: [],
898-
} as configUtils.AugmentationProperties,
884+
},
899885
);
900886

901887
const calculateAugmentationErrorMacro = test.macro({

0 commit comments

Comments
 (0)