mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Add something about setting up Postgres to run tests
This commit is contained in:
parent
3121a9f17b
commit
ef209011a8
|
|
@ -75,7 +75,20 @@ comment. Please avoid doing this if you can.
|
|||
We also have unit tests which we run via:
|
||||
|
||||
```bash
|
||||
go test --race ./...
|
||||
DENDRITE_TEST_SKIP_NODB=1 go test --race ./...
|
||||
```
|
||||
|
||||
This only runs SQLite database tests. If you wish to execute Postgres tests as well, you'll either need to
|
||||
have Postgres installed locally (`createdb` will be used) or have a remote/containerized Postgres instance
|
||||
available.
|
||||
|
||||
To configure the connection to a remote Postgres, you can use the following enviroment variables:
|
||||
|
||||
```bash
|
||||
POSTGRES_USER=postgres
|
||||
POSTGERS_PASSWORD=yourPostgresPassword
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_DB=postgres # the superuser database to use
|
||||
```
|
||||
|
||||
In general, we like submissions that come with tests. Anything that proves that the
|
||||
|
|
|
|||
|
|
@ -65,10 +65,7 @@ func createRemoteDB(t *testing.T, dbName, user, connStr string) {
|
|||
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
||||
}
|
||||
if err = db.Ping(); err != nil {
|
||||
// If we're unable to reach the database, it's unlikely that a postgres server is
|
||||
// available for testing. Set Required to false to skip the test instead of failing it.
|
||||
Required = false
|
||||
t.Logf("Note: tests require a postgres install accessible to the current user")
|
||||
|
||||
fatalError(t, "failed to open postgres conn with connstr=%s : %s", connStr, err)
|
||||
}
|
||||
_, err = db.Exec(fmt.Sprintf(`CREATE DATABASE %s;`, dbName))
|
||||
|
|
|
|||
Loading…
Reference in a new issue