diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca863cea..665f8701 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ Run `make setup-dev-env` to install local developer tools and run necessary services, such as mongodb, for the end-to-end tests. ## Unit Tests -Run `make test-unit` to run the unit tests. +For further details see [DEVELOPMENT.md](DEVELOPMENT.md#L84) ## End-to-End Tests End-to-End tests (e2e) are tests from the user perspective that validate that diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 6a4d82b5..d08bfcc8 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -80,3 +80,24 @@ Starting application at 127.0.0.1:3000 And you'll be up and running. As you edit and save code, the `buffalo dev` command will notice and automatically re-compile and restart the server. + +# Run unit tests + +In order to run unit tests, services they depend on must be running first: + +```console +make alldeps +``` + +and database created: + +```console +buffalo db create +buffalo db migrate up +``` + +then you can run the unit tests: + +```console +make test-unit +``` diff --git a/cmd/proxy/.env b/cmd/proxy/.env index 8e7b14f7..22ebef05 100644 --- a/cmd/proxy/.env +++ b/cmd/proxy/.env @@ -1 +1,3 @@ ATHENS_MONGO_STORAGE_URL=mongodb://127.0.0.1:27017 +GO_ENV=test_postgres +POP_PATH=$PWD/cmd/proxy diff --git a/scripts/test_unit.sh b/scripts/test_unit.sh index 6f9a21cd..e9c86e72 100755 --- a/scripts/test_unit.sh +++ b/scripts/test_unit.sh @@ -1,7 +1,9 @@ #!/bin/bash # test_unit.sh + +source cmd/proxy/.env + # Run the unit tests with the race detector and code coverage enabled set -xeuo pipefail - go test -race -coverprofile cover.out -covermode atomic ./...