Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidates DB_PORT_TEST, adds go-test script #1817

Merged
merged 2 commits into from Mar 5, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+15 −8
Diff settings

Always

Just for now

Copy path View file
3 .envrc
@@ -56,10 +56,13 @@ export MYMOVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Configuration needed for secure migrations.
export SECURE_MIGRATION_DIR="${MYMOVE_DIR}/local_migrations"
export SECURE_MIGRATION_SOURCE="local"

# Default DB configuration
export DB_PASSWORD=mysecretpassword
export DB_USER=postgres
export DB_HOST=localhost
export DB_PORT=5432
export DB_PORT_TEST=5433
export DB_NAME=dev_db

# Login.gov configuration
Copy path View file
@@ -26,10 +26,7 @@ endif
WEBSERVER_LDFLAGS=-X main.gitBranch=$(shell git branch | grep \* | cut -d ' ' -f2) -X main.gitCommit=$(shell git rev-list -1 HEAD)
DB_PORT_DEV=5432
DB_PORT_DOCKER=5432
ifndef CIRCLECI
DB_PORT_TEST=5433
LDFLAGS=
else
ifdef CIRCLECI
DB_PORT_TEST=5432
LDFLAGS=-linkmode external -extldflags -static
endif
Copy path View file
@@ -0,0 +1,7 @@
#!/bin/bash

This comment has been minimized.

Copy link
@chrisgilmerproj

chrisgilmerproj Mar 5, 2019

Contributor

#! /usr/bin/env bash please ;)

#
# go-test runs go test but with the correct DB port
# For example: bin/go-test ./pkg/models
#

DB_PORT=$DB_PORT_TEST go test "$@"

This comment has been minimized.

Copy link
@chrisgilmerproj
Copy path View file
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

export DB_NAME=test_db
export DB_PORT=5433
export DB_PORT=$DB_PORT_TEST
# shellcheck disable=SC1091,SC1090
. "$(dirname "$0")"/psql
Copy path View file
@@ -4,7 +4,7 @@ set -eu -o pipefail

# Runs both the webserver and Cypress in parallel
trap "kill %1" SIGINT
./bin/webserver --env test --db-port 5433 --login-gov-callback-port 4000 --no-tls-port 4000 &
./bin/webserver --env test --db-port "$DB_PORT_TEST" --login-gov-callback-port 4000 --no-tls-port 4000 &
npx cypress open || true

# Terminate the background webserver
Copy path View file
@@ -33,15 +33,15 @@ $ TEST_ACC_ENV=staging TEST_ACC_DOD_CERTIFICATES=1 make webserver_test
### Run All Tests in a Single Package

```console
$ DB_PORT=5433 go test ./pkg/handlers/internalapi/
$ bin/go-test ./pkg/handlers/internalapi/
```

### Run Tests with Names Matching a String

The following will run any Testify tests that have a name matching `Test_Name` in the `handlers/internalapi` package:

```console
$ DB_PORT=5433 go test ./pkg/handlers/internalapi/ -testify.m Test_Name
$ bin/go-test ./pkg/handlers/internalapi/ -testify.m Test_Name
```

## Run Tests when a File Changes
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.