Skip to content

Commit 1384ce4

Browse files
committed
Fixes spurious error messages in tests
Previously, `isAnalyzingDefaultBranch` was failing because there are some missing env vars: `GITHUB_SHA`, `GITHUB_REF`, and `GITHUB_EVENT_PATH`. Also, `checkout_path` is missing as an input. Rather than trying to set them to mock values, which would require setting the paths to existing paths in the file system, I chose to stub the entire function. I think this is fine since the point of the test is to check the ram and threads values, not testing the `isAnalyzingDefaultBranch` function.
1 parent 9dac9f7 commit 1384ce4

6 files changed

+7
-2
lines changed

lib/analyze-action-env.test.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-env.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-input.test.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-input.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze-action-env.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ test("analyze action with RAM & threads from environment variables", async (t) =
2929
.stub(actionsUtil, "createStatusReportBase")
3030
.resolves({} as actionsUtil.StatusReportBase);
3131
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
32+
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
33+
3234
const gitHubVersion: util.GitHubVersion = {
3335
type: util.GitHubVariant.DOTCOM,
3436
};

src/analyze-action-input.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
4545
optionalInputStub.withArgs("cleanup-level").returns("none");
4646
optionalInputStub.withArgs("expect-error").returns("false");
4747
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
48+
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
4849
setupActionsVars(tmpDir, tmpDir);
4950
mockFeatureFlagApiEndpoint(200, {});
5051

0 commit comments

Comments
 (0)