Skip to content

NewPGDB requires a connection string as input. Deps and tests update #9

NewPGDB requires a connection string as input. Deps and tests update

NewPGDB requires a connection string as input. Deps and tests update #9

Workflow file for this run

name: Setup PostgreSQL and test fitbit_pgdb
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
services:
postgres:
# Docker Hub image
image: postgres:14.5
# Provide the password for postgres
env:
POSTGRES_PASSWORD: pass
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: build
run: go build -v ./...
- name: test
env:
POSTGRES_HOST: localhost
DB_USER: fitbit
DB_PASS: fitbit
DB_NAME: fitbit
run: |
export PGPASSWORD=pass
psql -h localhost -p 5432 -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" -U postgres
psql -h localhost -p 5432 -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;" -U postgres
go test -v ./...