Skip to content

Commit 6cb83fa

Browse files
henrymercerCopilot
andcommitted
Construct UserConfig objects directly in the config-utils tests
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent a4a04dc commit 6cb83fa

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

‎src/config-utils.test.ts‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,11 @@ const simpleConfigFileContents = `
473473
queries:
474474
- uses: ./foo_file`;
475475

476-
/** The configuration in `simpleConfigFileContents`, as parsed from the `config` input. */
477-
const simpleConfigInput = yaml.load(simpleConfigFileContents) as UserConfig;
476+
/** The configuration in `simpleConfigFileContents`. */
477+
const simpleConfigInput: UserConfig = {
478+
name: "my config",
479+
queries: [{ uses: "./foo_file" }],
480+
};
478481

479482
/** A less minimal configuration file. */
480483
const otherConfigFileContents = `
@@ -561,16 +564,14 @@ test.serial(
561564
tempDir,
562565
);
563566

564-
const configInput = `
565-
name: my config
566-
queries:
567-
- uses: ./foo
568-
packs:
569-
javascript:
570-
- a/b@1.2.3
571-
python:
572-
- c/d@1.2.3
573-
`;
567+
const configInput: UserConfig = {
568+
name: "my config",
569+
queries: [{ uses: "./foo" }],
570+
packs: {
571+
javascript: ["a/b@1.2.3"],
572+
python: ["c/d@1.2.3"],
573+
},
574+
};
574575

575576
fs.mkdirSync(path.join(tempDir, "foo"));
576577

@@ -594,14 +595,14 @@ test.serial(
594595
createTestInitConfigInputs({
595596
languagesInput,
596597
configFile: configFilePath,
597-
configInput: yaml.load(configInput) as UserConfig,
598+
configInput,
598599
tempDir,
599600
codeql,
600601
workspacePath: tempDir,
601602
}),
602603
);
603604

604-
t.deepEqual(config.originalUserInput, yaml.load(configInput));
605+
t.deepEqual(config.originalUserInput, configInput);
605606
});
606607
},
607608
);
@@ -2520,12 +2521,15 @@ test("determineUserConfig - ignores config file input when both specified", asyn
25202521
});
25212522
});
25222523

2523-
/** The configuration from a `config` input that we might get from Default Setup. */
2524-
const defaultSetupConfigInput = yaml.load(`
2525-
threat-models: [local, remote]
2526-
default-setup:
2527-
org:
2528-
model-packs: [foo, bar]`) as UserConfig;
2524+
/** A `config` input that we might get from Default Setup. */
2525+
const defaultSetupConfigInput: UserConfig = {
2526+
"threat-models": ["local", "remote"],
2527+
"default-setup": {
2528+
org: {
2529+
"model-packs": ["foo", "bar"],
2530+
},
2531+
},
2532+
};
25292533

25302534
test("determineUserConfig - merges configs if FF is enabled in Default Setup", async (t) => {
25312535
await withTmpDir(async (tmpDir) => {

0 commit comments

Comments
 (0)