Skip to content

Instantly share code, notes, and snippets.

@andreybleme
Last active May 28, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreybleme/a09098ef5b32e4ae1703e1e12ab2ab1f to your computer and use it in GitHub Desktop.
Save andreybleme/a09098ef5b32e4ae1703e1e12ab2ab1f to your computer and use it in GitHub Desktop.
andreybleme.com | Integration tests with Docker
#!/bin/bash
CONTAINER_ID=$(docker run -p 5400:5432 -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -d postgres:9.6.5)
REDIS_CONTAINER_ID=$(docker run -p 6379:6379 -d redis:4.0-alpine)
echo "Running PG Container: $CONTAINER_ID"
echo "Running Redis Container: $REDIS_CONTAINER_ID"
# waits
sleep 5
# run db tests
export PG_URL=postgres://test:test@localhost:5400/test
PG_URL=$PG_URL npm run test
PG_URL=$PG_URL REDIS_SERVICE_URL=redis://localhost
# kill database containers
echo "Killing PG Container: $CONTAINER_ID"
docker rm -f $CONTAINER_ID
echo "Killing Redis Container: $REDIS_CONTAINER_ID"
docker rm -f $REDIS_CONTAINER_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment