Skip to content

Commit b10e27c

Browse files
committed
Document how to run DB tests locally
1 parent 6b8dd45 commit b10e27c

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ The general overview of what you will need to do:
3939
3. [Configure webhook forwarding](#configure-webhook-forwarding)
4040
4. Configure the `.env` file:
4141

42-
1. Copy `.env.sample` to `.env`
43-
2. `GITHUB_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings > Developer Settings > Personal Access Token, and create a new token. The `repo` permission should be sufficient.
44-
If this is not set, Triagebot will also look in `~/.gitconfig` in the `github.oauth-token` setting.
45-
3. `DATABASE_URL`: This is the URL to the database. See [Configuring a database](#configuring-a-database).
46-
4. `GITHUB_WEBHOOK_SECRET`: Enter the secret you entered in the webhook above.
47-
5. `RUST_LOG`: Set this to `debug`.
42+
1. Copy `.env.sample` to `.env`
43+
2. `GITHUB_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings > Developer Settings > Personal Access Token, and create a new token. The `repo` permission should be sufficient.
44+
If this is not set, Triagebot will also look in `~/.gitconfig` in the `github.oauth-token` setting.
45+
3. `DATABASE_URL`: This is the URL to the database. See [Configuring a database](#configuring-a-database).
46+
4. `GITHUB_WEBHOOK_SECRET`: Enter the secret you entered in the webhook above.
47+
5. `RUST_LOG`: Set this to `debug`.
4848

4949
5. Run `cargo run --bin triagebot`. This starts the http server listening for webhooks on port 8000.
5050
6. Add a `triagebot.toml` file to the main branch of your GitHub repo with whichever services you want to try out.
@@ -109,15 +109,28 @@ You need to sign up for a free account, and also deal with configuring the GitHu
109109
3. Configure GitHub webhooks in the test repo you created.
110110
In short:
111111

112-
1. Go to the settings page for your GitHub repo.
113-
2. Go to the webhook section.
114-
3. Click "Add webhook"
115-
4. Include the settings:
112+
1. Go to the settings page for your GitHub repo.
113+
2. Go to the webhook section.
114+
3. Click "Add webhook"
115+
4. Include the settings:
116116

117-
* Payload URL: This is the URL to your Triagebot server, for example http://7e9ea9dc.ngrok.io/github-hook. This URL is displayed when you ran the `ngrok` command above.
118-
* Content type: application/json
119-
* Secret: Enter a shared secret (some longish random text)
120-
* Events: "Send me everything"
117+
* Payload URL: This is the URL to your Triagebot server, for example http://7e9ea9dc.ngrok.io/github-hook. This URL is displayed when you ran the `ngrok` command above.
118+
* Content type: application/json
119+
* Secret: Enter a shared secret (some longish random text)
120+
* Events: "Send me everything"
121+
122+
### Cargo tests
123+
124+
You can run Cargo tests using `cargo test`. If you also want to run tests that access a Postgres database, you can specify an environment variables `TEST_DB_URL`, which should contain a connection string pointing to a running Postgres database instance:
125+
126+
```bash
127+
$ docker run --rm -it -p5432:5432 \
128+
-e POSTGRES_USER=triagebot \
129+
-e POSTGRES_PASSWORD=triagebot \
130+
-e POSTGRES_DB=triagebot \
131+
postgres:14
132+
$ TEST_DB_URL=postgres://triagebot:triagebot@localhost:5432/triagebot cargo test
133+
```
121134

122135
## License
123136

0 commit comments

Comments
 (0)