Skip to content

Commit

Permalink
Don't download sarama unless actually building mocks
Browse files Browse the repository at this point in the history
Previously it was downloading as soon as the Makefile was invoked, due
to the inline "go list" command.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Sep 20, 2021
1 parent 116c307 commit bf07afd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ BINARY_WIN=$(BINARY_NAME)-win
GOBIN := $(shell $(VGO) env GOPATH)/bin
MOCKERY := $(GOBIN)/mockery

SARAMA_PATH := $(shell $(VGO) list -f '{{.Dir}}' github.com/Shopify/sarama)

.DELETE_ON_ERROR:
GOFILES := $(shell find . -name '*.go' -print)

Expand Down Expand Up @@ -51,17 +49,19 @@ build-win:

${MOCKERY}:
$(VGO) install github.com/vektra/mockery/cmd/mockery@latest
sarama:
$(eval SARAMA_PATH := $(shell $(VGO) list -f '{{.Dir}}' github.com/Shopify/sarama))

define makemock
mocks: mocks-$(strip $(1))-$(strip $(2))
mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY}
mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY} sarama
${MOCKERY} --case underscore --dir $(1) --name $(2) --outpkg $(3) --output mocks/$(strip $(3))
endef

$(eval $(call makemock, internal/contractregistry, ContractStore, contractregistrymocks))
$(eval $(call makemock, internal/contractregistry, RemoteRegistry, contractregistrymocks))
$(eval $(call makemock, internal/eth, RPCClient, ethmocks))
$(eval $(call makemock, $(SARAMA_PATH), Client, saramamocks))
$(eval $(call makemock, $(SARAMA_PATH), ConsumerGroup, saramamocks))
$(eval $(call makemock, $(SARAMA_PATH), ConsumerGroupSession, saramamocks))
$(eval $(call makemock, $(SARAMA_PATH), ConsumerGroupClaim, saramamocks))
$(eval $(call makemock, $$(SARAMA_PATH), Client, saramamocks))
$(eval $(call makemock, $$(SARAMA_PATH), ConsumerGroup, saramamocks))
$(eval $(call makemock, $$(SARAMA_PATH), ConsumerGroupSession, saramamocks))
$(eval $(call makemock, $$(SARAMA_PATH), ConsumerGroupClaim, saramamocks))

0 comments on commit bf07afd

Please sign in to comment.