Skip to content

Commit 90697d6

Browse files
leighmccullochmaddyblue
authored andcommitted
Add more instructions for running tests (lib#750)
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.
1 parent 0677bdd commit 90697d6

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

README.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,7 @@ documentation at <http://godoc.org/github.com/lib/pq>.
1414

1515
## Tests
1616

17-
`go test` is used for testing. A running PostgreSQL server is
18-
required, with the ability to log in. The default database to connect
19-
to test with is "pqgotest," but it can be overridden using environment
20-
variables.
21-
22-
Example:
23-
24-
PGHOST=/run/postgresql go test github.com/lib/pq
25-
26-
Optionally, a benchmark suite can be run as part of the tests:
27-
28-
PGHOST=/run/postgresql go test -bench .
17+
`go test` is used for testing. See [TESTS.md](TESTS.md) for more details.
2918

3019
## Features
3120

TESTS.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Tests
2+
3+
## Running Tests
4+
5+
`go test` is used for testing. A running PostgreSQL
6+
server is required, with the ability to log in. The
7+
database to connect to test with is "pqgotest," on
8+
"localhost" but these can be overridden using [environment
9+
variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html).
10+
11+
Example:
12+
13+
PGHOST=/run/postgresql go test
14+
15+
## Benchmarks
16+
17+
A benchmark suite can be run as part of the tests:
18+
19+
go test -bench .
20+
21+
## Example setup (Docker)
22+
23+
Run a postgres container:
24+
25+
```
26+
docker run --expose 5432:5432 postgres
27+
```
28+
29+
Run tests:
30+
31+
```
32+
PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test
33+
```

0 commit comments

Comments
 (0)