Refactoring: Introduce common method to stub a config

This means that we don't need to update irrelevant test cases when we
add a new configuration property.
This commit is contained in:
Henry Mercer 2024-01-30 18:57:41 +00:00
parent ec42edcaab
commit d2e867f3be
18 changed files with 114 additions and 207 deletions

View file

@ -9,13 +9,20 @@ import * as sinon from "sinon";
import * as apiClient from "./api-client";
import { GitHubApiDetails } from "./api-client";
import * as codeql from "./codeql";
import { Config } from "./config-utils";
import {
CodeQLDefaultVersionInfo,
Feature,
FeatureEnablement,
} from "./feature-flags";
import { Logger } from "./logging";
import { HTTPError } from "./util";
import {
DEFAULT_DEBUG_ARTIFACT_NAME,
DEFAULT_DEBUG_DATABASE_NAME,
GitHubVariant,
GitHubVersion,
HTTPError,
} from "./util";
export const SAMPLE_DOTCOM_API_DETAILS = {
auth: "token",
@ -291,3 +298,29 @@ export function mockBundleDownloadApi({
return `${baseUrl}${relativeUrl}`;
}
export function createTestConfig(overrides: Partial<Config>): Config {
return Object.assign(
{},
{
languages: [],
originalUserInput: {},
tempDir: "",
codeQLCmd: "",
gitHubVersion: {
type: GitHubVariant.DOTCOM,
} as GitHubVersion,
dbLocation: "",
debugMode: false,
debugArtifactName: DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: DEFAULT_DEBUG_DATABASE_NAME,
augmentationProperties: {
packsInputCombines: false,
queriesInputCombines: false,
},
trapCaches: {},
trapCacheDownloadTime: 0,
},
overrides,
);
}