Stub feature flag API endpoint in tests

This commit is contained in:
Henry Mercer 2021-12-16 13:30:31 +00:00
parent 6d62c245ec
commit 254816c2d2
12 changed files with 84 additions and 97 deletions

View file

@ -4,7 +4,11 @@ import * as sinon from "sinon";
import * as actionsUtil from "./actions-util";
import * as analyze from "./analyze";
import * as configUtils from "./config-utils";
import { setupTests, setupActionsVars } from "./testing-utils";
import {
setupTests,
setupActionsVars,
mockFeatureFlagApiEndpoint,
} from "./testing-utils";
import * as util from "./util";
setupTests(test);
@ -25,8 +29,7 @@ test("analyze action with RAM & threads from environment variables", async (t) =
.resolves({} as actionsUtil.StatusReportBase);
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
sinon.stub(configUtils, "getConfig").resolves({
// Use GHES so we don't try to call the feature flags API endpoint
gitHubVersion: { type: util.GitHubVariant.GHES, version: "3.0.0" },
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
languages: [],
} as unknown as configUtils.Config);
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
@ -35,6 +38,7 @@ test("analyze action with RAM & threads from environment variables", async (t) =
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
optionalInputStub.withArgs("cleanup-level").returns("none");
setupActionsVars(tmpDir, tmpDir);
mockFeatureFlagApiEndpoint(200, {});
// When there are no action inputs for RAM and threads, the action uses
// environment variables (passed down from the init action) to set RAM and