Tests: no network calls! - #1975
Conversation
Oh wow, you're right! No, it is not necessary. I simply forgot (apparently I fixed the same problem several times over the years... 🤦). |
When testing whether a given `/allow` command yields the expected result, let's mock out the actual GitHub REST API call. Signed-off-by: Johannes Schindelin <[email protected]>
30be28d to
68a8efc
Compare
| }; | ||
|
|
||
| ci.setGHGetPRComment(comment); | ||
| ci.letGHGetGitHubUserInfoThrow("is not a valid GitHub username"); |
There was a problem hiding this comment.
This test was originally intended to verify this line was run in CIHelper:
throw new Error(`User ${accountName} is not a valid GitHub username: ${reason}`);
Running the tests locally, the error is Error: User bad_@@@@ is not a valid GitHub username: Error: Need a GitHub token for gitgitgadget, which has as the reason an error thrown by GitHubGlue (and no network access). If you want to verify there is no network while still allowing the original test, how about:
const noNetwork = "No net";
ci.letGHGetGitHubUserInfoThrow(noNetwork);
await ...
expect ...
expect(ci.addPRCommentCalls[0][1]).toMatch(noNetwork); // new test for no network access
There was a problem hiding this comment.
Oh wow, never mind! I must have been in a situation when I developed the patch originally where I had lost network access (being happy about Git's distributed nature!). However, I just reran the test suite after disconnecting from the network, and it all passed:
Test Suites: 26 passed, 26 total
Tests: 152 passed, 152 total
Snapshots: 0 total
Time: 115.744 s, estimated 116 s
Ran all test suites.
I should have verified whether this patch is still needed before opening this PR, but I keep forgetting that when rebasing branch thickets, sorry!!!
|
This patch is not actually needed to run the test suite without network access. Sorry for the noise! |
As promised, this is my next attempt at removing network calls during tests (so that they would pass even when stuck in a plane without internet connection).