Skip to content

Commit

Permalink
Bring more clarity on how to run unit tests (gomods#449)
Browse files Browse the repository at this point in the history
* The commit brings more clarity on how to run unut tests.

The commit chages behaivour of `make test-unit` by adding sourcing of
env vars. Documentation is updated to provide more clarity on how to run
unit tests.

* changed list of commands to run before unit tests

* moved env vars to .env

* removed dduplicated env var

* returned conventional file name in script

* link to DEVELOPMENT.md

* fixed typo

* moved env var export to script

* removed export of tmp folder
  • Loading branch information
adyach authored and Rob j Loranger committed Aug 11, 2018
1 parent 8382266 commit 051f388
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 2 additions & 0 deletions cmd/proxy/.env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ATHENS_MONGO_STORAGE_URL=mongodb://127.0.0.1:27017
GO_ENV=test_postgres
POP_PATH=$PWD/cmd/proxy
4 changes: 3 additions & 1 deletion scripts/test_unit.sh
Original file line number Diff line number Diff line change
@@ -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 ./...

0 comments on commit 051f388

Please sign in to comment.