Skip to content

Commit

Permalink
Fixes spurious error messages in tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aeisenberg committed Nov 29, 2022
1 parent 9dac9f7 commit 1384ce4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/analyze-action-env.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action-env.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/analyze-action-input.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action-input.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/analyze-action-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ test("analyze action with RAM & threads from environment variables", async (t) =
.stub(actionsUtil, "createStatusReportBase")
.resolves({} as actionsUtil.StatusReportBase);
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);

const gitHubVersion: util.GitHubVersion = {
type: util.GitHubVariant.DOTCOM,
};
Expand Down
1 change: 1 addition & 0 deletions src/analyze-action-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
optionalInputStub.withArgs("cleanup-level").returns("none");
optionalInputStub.withArgs("expect-error").returns("false");
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
setupActionsVars(tmpDir, tmpDir);
mockFeatureFlagApiEndpoint(200, {});

Expand Down

0 comments on commit 1384ce4

Please # to comment.