Move makeVersionOutput to testing-utils.js

This commit is contained in:
Michael B. Gale 2023-10-04 15:45:42 +01:00
parent a402be8739
commit e827ad5b71
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
18 changed files with 110 additions and 114 deletions

View file

@ -443,21 +443,6 @@ function resolveFunction<T>(
return partialCodeql[methodName];
}
/**
* Constructs a `VersionOutput` object for testing purposes only.
*/
export const makeVersionOutput = (version: string): VersionOutput => ({
productName: "CodeQL",
vendor: "GitHub",
sha: "",
branches: [],
copyright: "",
unpackedLocation: "",
configFileLocation: "",
configFileFound: false,
version,
});
/**
* Set the functionality for CodeQL methods. Only for use in tests.
*
@ -470,7 +455,20 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
getVersion: resolveFunction(
partialCodeql,
"getVersion",
() => new Promise((resolve) => resolve(makeVersionOutput("1.0.0"))),
() =>
new Promise((resolve) =>
resolve({
productName: "CodeQL",
vendor: "GitHub",
sha: "",
branches: [],
copyright: "",
unpackedLocation: "",
configFileLocation: "",
configFileFound: false,
version: "1.0.0",
}),
),
),
printVersion: resolveFunction(partialCodeql, "printVersion"),
databaseInitCluster: resolveFunction(partialCodeql, "databaseInitCluster"),