Skip to content

Commit b3dffd6

Browse files
committed
Add some docs on testing
1 parent 2ffe1ef commit b3dffd6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ The general overview of what you will need to do:
4141
Or, you can use a service such as https://ngrok.com/ to access on your local dev machine via localhost.
4242
Installation is fairly simple, though requires setting up a (free) account.
4343
Run the command `ngrok http 8000` to forward to port 8000 on localhost.
44+
45+
> Note: GitHub has a webhook forwarding service available in beta.
46+
> See [cli/gh-webhook](https://docs.github.com/en/developers/webhooks-and-events/webhooks/receiving-webhooks-with-the-github-cli) for more information.
47+
> This is super easy to use, and doesn't require manually configuring webhook settings.
48+
> The command to run looks something like:
49+
>
50+
> ```sh
51+
> gh webhook forward --repo=ehuss/triagebot-test --events=* \
52+
> --url=http://127.0.0.1:8000/github-hook --secret somelongsekrit
53+
> ```
54+
>
55+
> Where the value in `--secret` is the secret value you place in `GITHUB_WEBHOOK_SECRET` described below, and `--repo` is the repo you want to test against.
56+
4457
4. Create a GitHub repo to run some tests on.
4558
5. Configure the webhook in your GitHub repo.
4659
I recommend at least skimming the [GitHub webhook documentation](https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks) if you are not familiar with webhooks. In short:
@@ -67,6 +80,17 @@ The general overview of what you will need to do:
6780
8. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
6881
9. Try interacting with your repo, such as issuing `@rustbot` commands or interacting with PRs and issues (depending on which services you enabled in `triagebot.toml`). Watch the logs from the server to see what's going on.
6982
83+
## Tests
84+
85+
When possible, writing unittests is very helpful and one of the easiest ways to test.
86+
For more advanced testing, there is an integration test called `testsuite` which provides an end-to-end service for testing triagebot.
87+
There are two parts to it:
88+
89+
* [`github_client`](tests/github_client/mod.rs) — Tests specifically targeting `GithubClient`.
90+
This sets up an HTTP server that mimics api.github.com and verifies the client's behavior.
91+
* [`server_test`](tests/server_test/mod.rs) — This tests the `triagebot` server itself and its behavior when it receives a webhook.
92+
This launches the `triagebot` server, sets up HTTP servers to intercept api.github.com requests, launches PostgreSQL in a sandbox, and then injects webhook events into the `triagebot` server and validates its response.
93+
7094
## License
7195
7296
Triagebot is distributed under the terms of both the MIT license and the

0 commit comments

Comments
 (0)