Move makeVersionOutput to testing-utils.js
This commit is contained in:
parent
a402be8739
commit
e827ad5b71
18 changed files with 110 additions and 114 deletions
|
|
@ -27,6 +27,7 @@ import {
|
|||
SAMPLE_DOTCOM_API_DETAILS,
|
||||
SAMPLE_DEFAULT_CLI_VERSION,
|
||||
mockBundleDownloadApi,
|
||||
makeVersionOutput,
|
||||
} from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
import { initializeEnvironment } from "./util";
|
||||
|
|
@ -565,7 +566,7 @@ test("databaseInitCluster() without injected codescanning config", async (t) =>
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.10.5"));
|
||||
.resolves(makeVersionOutput("2.10.5"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -610,7 +611,7 @@ const injectedConfigMacro = test.macro({
|
|||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(
|
||||
codeql.makeVersionOutput(
|
||||
makeVersionOutput(
|
||||
featureConfig[Feature.CliConfigFileEnabled].minimumVersion ||
|
||||
"1.0.0",
|
||||
),
|
||||
|
|
@ -836,9 +837,7 @@ test("does not pass a code scanning config or qlconfig file to the CLI when CLI
|
|||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
// stubbed version doesn't matter. It just needs to be valid semver.
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("0.0.0"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("0.0.0"));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -870,9 +869,7 @@ test("passes a code scanning config AND qlconfig to the CLI when CLI config pass
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(
|
||||
codeql.makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG),
|
||||
);
|
||||
.resolves(makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -904,7 +901,7 @@ test("passes a code scanning config BUT NOT a qlconfig to the CLI when CLI confi
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.12.2"));
|
||||
.resolves(makeVersionOutput("2.12.2"));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -939,9 +936,7 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(
|
||||
codeql.makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG),
|
||||
);
|
||||
.resolves(makeVersionOutput(codeql.CODEQL_VERSION_INIT_WITH_QLCONFIG));
|
||||
|
||||
await codeqlObject.databaseInitCluster(
|
||||
{ ...stubConfig, tempDir },
|
||||
|
|
@ -963,9 +958,7 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
|
|||
test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.11.3"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.3"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -991,9 +984,7 @@ test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3"
|
|||
test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.11.2"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.2"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -1056,7 +1047,7 @@ for (const {
|
|||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput(codeqlVersion));
|
||||
.resolves(makeVersionOutput(codeqlVersion));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
await codeqlObject.databaseInterpretResults(
|
||||
|
|
@ -1099,9 +1090,7 @@ test("database finalize recognises JavaScript no code found error on CodeQL 2.11
|
|||
2020-09-07T17:39:53.9251124Z [2020-09-07 17:39:53] [ERROR] Spawned process exited abnormally (code 255; tried to run: [/opt/hostedtoolcache/CodeQL/0.0.0-20200630/x64/codeql/javascript/tools/autobuild.sh])`,
|
||||
);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1118,9 +1107,7 @@ test("database finalize recognises JavaScript no code found error on CodeQL 2.11
|
|||
test("database finalize overrides no code found error on CodeQL 2.11.6", async (t) => {
|
||||
stubToolRunnerConstructor(32);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.11.6"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.11.6"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1140,9 +1127,7 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",
|
|||
"https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build.";
|
||||
stubToolRunnerConstructor(32, cliMessage);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
@ -1167,9 +1152,7 @@ test("runTool summarizes several fatal errors", async (t) => {
|
|||
`${heapError}\n${datasetImportError}.`;
|
||||
stubToolRunnerConstructor(32, cliStderr);
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
sinon
|
||||
.stub(codeqlObject, "getVersion")
|
||||
.resolves(codeql.makeVersionOutput("2.12.4"));
|
||||
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionOutput("2.12.4"));
|
||||
// safeWhich throws because of the test CodeQL object.
|
||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue