Skip to content

Commit

Permalink
Add more instructions for running tests (#750)
Browse files Browse the repository at this point in the history
What
===
Add more instructions for running tests.

Why
===
For those starting out and not familiar with how to get a PostgresSQL
up and running for tests some examples would be helpful.
  • Loading branch information
leighmcculloch authored and maddyblue committed May 23, 2018
1 parent 0677bdd commit 90697d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@ documentation at <http://godoc.org/github.com/lib/pq>.

## Tests

`go test` is used for testing. A running PostgreSQL server is
required, with the ability to log in. The default database to connect
to test with is "pqgotest," but it can be overridden using environment
variables.

Example:

PGHOST=/run/postgresql go test github.com/lib/pq

Optionally, a benchmark suite can be run as part of the tests:

PGHOST=/run/postgresql go test -bench .
`go test` is used for testing. See [TESTS.md](TESTS.md) for more details.

## Features

Expand Down
33 changes: 33 additions & 0 deletions TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Tests

## Running Tests

`go test` is used for testing. A running PostgreSQL
server is required, with the ability to log in. The
database to connect to test with is "pqgotest," on
"localhost" but these can be overridden using [environment
variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html).

Example:

PGHOST=/run/postgresql go test

## Benchmarks

A benchmark suite can be run as part of the tests:

go test -bench .

## Example setup (Docker)

Run a postgres container:

```
docker run --expose 5432:5432 postgres
```

Run tests:

```
PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test
```

0 comments on commit 90697d6

Please sign in to comment.