Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 3a4f681

Browse files
use go generate for mockgen
1 parent 200113c commit 3a4f681

7 files changed

+34
-7
lines changed

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
1111
ENV GO111MODULE on
1212
# Install Go Tools
1313
RUN go get -u golang.org/x/lint/golint
14-
RUN go get -u github.com/golang/mock/mockgen
1514

1615

1716
WORKDIR /src

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,19 @@ Make sure you use the latest version in the image tag. Alternatiely you can use
580580
likely to break at any time.
581581

582582

583+
## Testing
584+
585+
### Unit Tests
586+
587+
To unit test *aws-nuke*, some tests require [gomock](https://github.com/golang/mock) to run.
588+
This will run via `go generate ./...`, but is automatically run via `make test`.
589+
To run the unit tests:
590+
591+
```bash
592+
make test
593+
```
594+
595+
583596
## Contact Channels
584597

585598
Feel free to create a GitHub Issue for any questions, bug reports or feature

generate_mocks

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
go run github.com/golang/mock/mockgen -source $(go list -m -f "{{.Dir}}" "github.com/aws/aws-sdk-go")/service/cloudformation/cloudformationiface/interface.go -destination mocks/mock_cloudformationiface/mock.go

generate_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
//go:generate ./generate_mocks

go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO
7171
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7272
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
7373
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
74+
golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg=
7475
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
7576
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
7677
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

golang.mk

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ vet: vendor
4141
lint:
4242
$(foreach pkg,$(GOPKGS),golint $(pkg);)
4343

44-
generate_mocks:
44+
go_generate:
4545
rm mocks -rvf
46-
mockgen -source $(shell go list -m -f "{{.Dir}}" "github.com/aws/aws-sdk-go")/service/cloudformation/cloudformationiface/interface.go -destination mocks/mock_cloudformationiface/mock.go
46+
go generate ./...
4747

4848
test_packages: vendor
4949
go test $(GOPKGS)
5050

5151
test_format:
5252
gofmt -s -l $(GOFILES)
5353

54-
test: test_format generate_mocks vet lint test_packages
54+
test: test_format go_generate vet lint test_packages
5555

56-
cov: generate_mocks
56+
cov: go_generate
5757
gocov test -v $(GOPKGS) \
5858
| gocov-html > coverage.html
5959

@@ -80,5 +80,5 @@ install: vendor test
8080
$(BUILD_FLAGS);)
8181

8282
clean:
83-
rm dist/ -rv
84-
rm mocks/ -rv
83+
rm dist/ -rvf
84+
rm mocks/ -rvf

tools/tools.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// +build tools
2+
3+
package main
4+
5+
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
6+
import (
7+
_ "github.com/golang/mock/mockgen"
8+
)

0 commit comments

Comments
 (0)