/test-template

Primary LanguageGoMIT LicenseMIT

Test Template

Prerequisites

Usage

Export necessary variable

export PORT=:8080
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DB=testdb

Check docker compose config

docker-compose config

Run docker compose to setup DB

docker-compose up -d

Run the server

go run main.go

Run unit tests

go test ./... -race -coverprofile cover.out
go tool cover -func cover.out

Coverage

go tool cover -func cover.out | grep total | awk '{print $3}'