Skip to content

Commit

Permalink
.: describe how to run unit tests in CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
staebler committed Dec 15, 2018
1 parent 0ce4e26 commit 355cad8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ For contributors who want to work up pull requests, the workflow is roughly:
hack/tf-fmt.sh -list -check
hack/tf-lint.sh
hack/yaml-lint.sh
hack/go-test.sh
```
7. Submit a pull request to the original repository.
8. The [repo](OWNERS) [owners](OWNERS_ALIASES) will respond to your issue promptly, following [the ususal Prow workflow][prow-review].
Expand Down Expand Up @@ -86,6 +87,21 @@ second line is always blank, and other lines should be wrapped at 80 characters.
This allows the message to be easier to read on GitHub as well as in various
git tools.
## Generating Test Mocks
Some unit tests use mocks that are generated with gomock. If the underlying interface for a mock changes, then the mock will need to be regenerated. Use the following to regenerate all of the mocks under the pkg package.
```
go generate ./pkg/...
```
This requires gomock and mockgen. These can be installed by running the following.
```
go get -u github.com/golang/mock/gomock
go get -u github.com/golang/mock/mockgen
```
[golang-style]: https://github.com/golang/go/wiki/CodeReviewComments
[disclosure]: https://coreos.com/security/disclosure/
[new-issue]: https://github.com/openshift/installer/issues/new
Expand Down
13 changes: 13 additions & 0 deletions hack/go-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# Example: ./hack/go-test.sh

if [ "$IS_CONTAINER" != "" ]; then
go test ./cmd/... ./data/... ./pkg/... "${@}"
else
podman run --rm \
--env IS_CONTAINER=TRUE \
--volume "${PWD}:/go/src/github.com/openshift/installer:z" \
--workdir /go/src/github.com/openshift/installer \
docker.io/openshift/origin-release:golang-1.10 \
./hack/go-test.sh "${@}"
fi

0 comments on commit 355cad8

Please sign in to comment.