From 6cb83faca671f36b6e1e0776fb72122ea212bc69 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Mon, 5 Oct 2026 14:02:22 +0100 Subject: [PATCH] Construct `UserConfig` objects directly in the `config-utils` tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- src/config-utils.test.ts | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index 3ea71ebc4..c757f4f95 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -473,8 +473,11 @@ const simpleConfigFileContents = ` queries: - uses: ./foo_file`; -/** The configuration in `simpleConfigFileContents`, as parsed from the `config` input. */ -const simpleConfigInput = yaml.load(simpleConfigFileContents) as UserConfig; +/** The configuration in `simpleConfigFileContents`. */ +const simpleConfigInput: UserConfig = { + name: "my config", + queries: [{ uses: "./foo_file" }], +}; /** A less minimal configuration file. */ const otherConfigFileContents = ` @@ -561,16 +564,14 @@ test.serial( tempDir, ); - const configInput = ` - name: my config - queries: - - uses: ./foo - packs: - javascript: - - a/b@1.2.3 - python: - - c/d@1.2.3 - `; + const configInput: UserConfig = { + name: "my config", + queries: [{ uses: "./foo" }], + packs: { + javascript: ["a/b@1.2.3"], + python: ["c/d@1.2.3"], + }, + }; fs.mkdirSync(path.join(tempDir, "foo")); @@ -594,14 +595,14 @@ test.serial( createTestInitConfigInputs({ languagesInput, configFile: configFilePath, - configInput: yaml.load(configInput) as UserConfig, + configInput, tempDir, codeql, workspacePath: tempDir, }), ); - t.deepEqual(config.originalUserInput, yaml.load(configInput)); + t.deepEqual(config.originalUserInput, configInput); }); }, ); @@ -2520,12 +2521,15 @@ test("determineUserConfig - ignores config file input when both specified", asyn }); }); -/** The configuration from a `config` input that we might get from Default Setup. */ -const defaultSetupConfigInput = yaml.load(` - threat-models: [local, remote] - default-setup: - org: - model-packs: [foo, bar]`) as UserConfig; +/** A `config` input that we might get from Default Setup. */ +const defaultSetupConfigInput: UserConfig = { + "threat-models": ["local", "remote"], + "default-setup": { + org: { + "model-packs": ["foo", "bar"], + }, + }, +}; test("determineUserConfig - merges configs if FF is enabled in Default Setup", async (t) => { await withTmpDir(async (tmpDir) => {