Postgres test instructions with brew instructions

This commit is contained in:
tim 2017-11-30 15:40:31 +00:00
parent 1c8c652e5b
commit 881d9e8eb7

View File

@ -244,29 +244,34 @@ In order to use these functions, you need to explicitly import their correspondi
### Tests and Postgres ### Tests and Postgres
To ```stack test``` with Postgresql you'll need to set the Postgres flag to true in esqueleto.cabal To ```stack test``` with Postgresql you'll need to set the Postgres flag for [esqueleto.cabal](esqueleto.cabal)
Do this from the command line with: ```stack test --flag esqueleto:postgresql```
``` If you don't have Postgres install it.
Flag postgresql Using apt-get it's just:
Description: test postgresql. default is to test sqlite.
Default: False
```
If you don't have Postgres install it. Using apt-get it's just:
``` ```
sudo apt-get install postgresql postgresql-contrib sudo apt-get install postgresql postgresql-contrib
sudo apt-get install libpq-dev sudo apt-get install libpq-dev
``` ```
The connection details are located near the bottom of the test/Test.hs file: Using homebrew on OSx
```
brew install postgresql
brew install libpq
```
Detailed instructions on the Postgres wike [here](https://wiki.postgresql.org/wiki/Detailed_installation_guides)
The connection details are located near the bottom of the [test/Test.hs](test/Test.hs) file:
``` ```
#if defined(WITH_POSTGRESQL) #if defined(WITH_POSTGRESQL)
withPostgresqlConn "host=localhost port=5432 user=esqutest password=esqutest dbname=esqutest" withPostgresqlConn "host=localhost port=5432 user=esqutest password=esqutest dbname=esqutest"
``` ```
You can change these if you like but to just get them working set up as follows: You can change these if you like but to just get them working set up as follows on linux:
```$ sudo -u postgres createuser esqutest``` ```$ sudo -u postgres createuser esqutest```
@ -277,4 +282,17 @@ $ sudo -u postgres psql
postgres=# \password esqutest postgres=# \password esqutest
``` ```
Now ```stack test``` should envoke and pass all the Postgres tests.
And on osx
```$ createuser esqutest```
```$ createdb esqutest```
```
$ psql postgres
postgres=# \password esqutest
```
Now ```stack test --flag esqueleto:postgresql``` should envoke and pass all the Postgres tests.