Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Local testing setup #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Environment variables for docker-compose
PGHOST=db
PGPASSWORD=pg-cursor-test
POSTGRES_PASSWORD=pg-cursor-test
PGUSER=postgres
POSTGRES_VERSION=9.6
NODE_VERSION=8
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: node_js
dist: trusty
sudo: false
node_js:
- "4.2"
- "6"
- "8"
- "10"
env:
- PGUSER=postgres
services:
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ ___note___: this depends on _either_ `npm install pg` or `npm install pg.js`, bu

### :star: [Documentation](https://node-postgres.com/api/cursor) :star:

### Testing

To run the test suite against all supported versions of PostgreSQL and
Node.js locally, you will need to install and run Docker, and then run

./test_all_versions.sh

This will take a while, and consume a lot of bandwidth downloading Docker
images.

Due to a [bug in npm][npmbug], the output is very verbose, but with a bit of
scrolling, you should hopefully see green checkmarks for every test run.

[npmbug]: https://npm.community/t/npm-rebuild-silent-is-not-silent/3834

### license

The MIT License (MIT)
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3"

services:
db:
image: "postgres:${POSTGRES_VERSION}"
restart: always
expose:
- 5432
environment:
- POSTGRES_PASSWORD
test:
image: "node:${NODE_VERSION}"
links:
- db
environment:
- PGHOST
- PGPASSWORD
- PGUSER
working_dir: /app
volumes:
- .:/app
command: bash -c "
npm rebuild --silent &&
npm test "
24 changes: 24 additions & 0 deletions test/test_all_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

node_versions='6 8 10'
pg_versions='9.6 10 11'

trap cleanup 0 1 2 3 6
set -e

function cleanup {
docker-compose down
}

for node_version in $node_versions
do
export NODE_VERSION=$node_version
for pg_version in $pg_versions
do
export POSTGRES_VERSION=$pg_version
echo "Running tests with Node v$node_version, PostgreSQL v$pg_version..."
docker-compose run --rm test
docker-compose down
done
done
echo "All done"