Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic mockgen for pkg/mock #2090

Closed
zroubalik opened this issue Sep 2, 2021 · 1 comment · Fixed by #2137
Closed

Add automatic mockgen for pkg/mock #2090

zroubalik opened this issue Sep 2, 2021 · 1 comment · Fixed by #2137
Labels
feature-request All issues for new features that have not been committed to Hacktoberfest help wanted Looking for support from community

Comments

@zroubalik
Copy link
Member

zroubalik commented Sep 2, 2021

Proposal

There are several mock interfaces generated from sources for testing purposes in pkg/mock. These interfaces were generated manually by running commands:

mockgen -destination=pkg/mock/mock_scaling/mock_interface.go -package=mock_scaling -source=pkg/scaling/scale_handler.go
mockgen -destination=pkg/mock/mock_scaler/mock_scaler.go -package=mock_scalers -source=pkg/scalers/scaler.go
mockgen -destination=pkg/mock/mock_scale/mock_interfaces.go -package=mock_scale -source=/Users/zroubali/go/pkg/mod/k8s.io/client-go@v0.22.1/scale/interfaces.go
mockgen -destination=pkg/mock/mock_client/mock_interfaces.go -package=mock_client -source=/Users/zroubali/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.9.6/pkg/client/interfaces.go

We should add a target to Makefile to regenerate this mock interfaces automatically when there is a change in the source files. mockgen installation should be handled by as well, similar way how kustomize or other tools are being installed in Makefile:

keda/Makefile

Lines 203 to 213 in 00b2972

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
ENVTEST = $(shell pwd)/bin/setup-envtest
envtest: ## Download envtest-setup locally if necessary.
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

@zroubalik zroubalik added help wanted Looking for support from community feature-request All issues for new features that have not been committed to labels Sep 2, 2021
@mihaitodor
Copy link
Contributor

I opened #2137 to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request All issues for new features that have not been committed to Hacktoberfest help wanted Looking for support from community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants