Skip to content

Commit

Permalink
Add mocks for testing network allocator
Browse files Browse the repository at this point in the history
Adds mocks, and the makefile rules to generate them. Readds a vendoring
of the mocking library.

Signed-off-by: Drew Erny <drew.erny@docker.com>
  • Loading branch information
dperny committed Apr 30, 2018
1 parent de20b9d commit 0d5b454
Show file tree
Hide file tree
Showing 11 changed files with 1,604 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Makefile
Expand Up @@ -24,6 +24,8 @@ VNDR=$(shell which vndr || echo '')

GO_LDFLAGS=-ldflags "-X `go list ./version`.Version=$(VERSION)"

MOCKS_PACKAGE=mocks

.PHONY: clean all AUTHORS fmt vet lint build binaries test integration setup generate protos checkprotos coverage ci check help install uninstall dep-validate
.DEFAULT: default

Expand All @@ -49,6 +51,7 @@ setup: ## install dependencies
@go get -u github.com/client9/misspell/cmd/misspell
@go get -u github.com/lk4d4/vndr
@go get -u github.com/stevvooe/protobuild
@go get -u github.com/golang/mock/mockgen

generate: protos
@echo "🐳 $@"
Expand Down Expand Up @@ -119,8 +122,9 @@ bin/%: cmd/% FORCE
binaries: $(BINARIES) ## build binaries
@echo "🐳 $@"

clean: ## clean up binaries
clean: ## clean up binaries and mocks
@echo "🐳 $@"
@rm -r $(MOCKS_PACKAGE)
@rm -f $(BINARIES)

install: $(BINARIES) ## install binaries
Expand Down Expand Up @@ -157,3 +161,18 @@ dep-validate:
(echo >&2 "+ inconsistent dependencies! what you have in vendor.conf does not match with what you have in vendor" && false)
@rm -Rf vendor
@mv .vendor.bak vendor

mocks: mock-ipam mock-driver mock-port
@echo "🐳 $@"

mock-ipam: manager/allocator/network/ipam/ipam.go
mkdir -p mocks/mock_ipam/
mockgen -source=$^ -destination=$(MOCKS_PACKAGE)/mock_ipam/mock_ipam.go

mock-driver: manager/allocator/network/driver/driver.go
mkdir -p mocks/mock_driver/
mockgen -source=$^ -destination=$(MOCKS_PACKAGE)/mock_driver/mock_driver.go

mock-port: manager/allocator/network/port/port.go
mkdir -p mocks/mock_port/
mockgen -source=$^ -destination=$(MOCKS_PACKAGE)/mock_port/mock_port.go
133 changes: 133 additions & 0 deletions mocks/mock_driver/mock_driver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 150 additions & 0 deletions mocks/mock_ipam/mock_ipam.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d5b454

Please sign in to comment.