forked from mbasa/pgGeocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# pgGeocoder Tests | ||
|
||
## Requirements | ||
|
||
* [pgTAP](https://pgtap.org/) | ||
* [pg_prove](https://pgtap.org/pg_prove.html) | ||
* Perl | ||
|
||
### Install pgTAP | ||
|
||
```bash | ||
git clone git@github.com:theory/pgtap.git | ||
cd pgtap | ||
make | ||
make install | ||
``` | ||
|
||
### Install pg_prove | ||
|
||
macOS: | ||
```bash | ||
brew install perl | ||
cpan TAP::Parser::SourceHandler::pgTAP | ||
ln -s $(find `brew --prefix` -name pg_prove) symlink it into $(brew --prefix)/bin | ||
``` | ||
|
||
Linux: (TODO: check actual environment) | ||
```bash | ||
cpan TAP::Parser::SourceHandler::pgTAP | ||
``` | ||
|
||
## Setup test data | ||
|
||
Setup smaller test data which can be used in GitHub Actions. | ||
|
||
### Load test data from `fixtures/address_*.csv` | ||
|
||
```bash | ||
cp tests/.env.test tests/.env | ||
bash tests/create_test_db_from_fixtures.sh | ||
``` | ||
Default test database name is `addresses_test`, but it can be changed in `tests/.env`. | ||
|
||
### Update fixtures csv from production database tables | ||
|
||
```bash | ||
bash tests/dump_prod_tables_to_fixtures.sh | ||
``` | ||
`address_t`, `address_s` and `address_o` tables basic columns are dumped to `fixtures/address_*.csv` files. | ||
|
||
## Run tests | ||
|
||
### normalize-japanese-addresses tests | ||
|
||
Go to the test directory. | ||
```bash | ||
cd tests/normalize-japanese-addresses | ||
``` | ||
|
||
Run pgTAP tests directly. | ||
```bash | ||
psql -U postgres -d addresses_test -f addresses.test.sql | ||
psql -U postgres -d addresses_test -f main.test.sql | ||
``` | ||
|
||
Or run pg_prove tests. | ||
```bash | ||
pg_prove -U postgres -d addresses_test addresses.test.sql | ||
pg_prove -U postgres -d addresses_test main.test.sql | ||
``` | ||
|
||
To detect error, using pg_prove is recommended. |