-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support vektra/mockery #24
Comments
I'm just curious how this would be used. repos:
- repo: https://github.com/bhundven/golang-pre-commit
rev: v1
hooks:
- id: go-build
- id: go-mockery
- id: go-unit-tests right? Or mockery runs the tests? |
Mockery is about generating code that can be used in tests. It generates it from code my looking at interfaces. It's a kind of Mocks can be used in tests of the package itself, but also by code using the Go module as library in external code. For this reason, it's important to update code from source. The best example I'm able to think about is to consider an interface had two methods type Whatever interface {
Foo() string
Bar() string
} So the code and mocks supported Foo() and Bar() Now the maintainer removes Bar() from the interface, if mockery is not called, the Mock will still have Bar() Tests will pass for people using mocked Bar in their tests, but Bar was removed, so their code will be broken without them to know. TL; DR; Using it as a pre-commit hook is important because it will make sure to update the mocks before committing Mockery doesn't launch test, it generates code that can be used by the tests There is no dependency between running test, using go build and launching mockery The user defining the pre-commit hooks in their .pre-commit-config.yaml will be the one who knows what they need to launch and in what order |
Gotcha. I'll get something for you to review tomorrow. |
Please also consider including the people who were looking for this feature. I mentioned them in this message |
Closes: #24 Signed-off-by: Bryan Hundven <[email protected]>
Test adding mockery: repos:
- repo: https://github.com/bhundven/golang-pre-commit
rev: feat/mockery
hooks:
- id: generate-mockery Let me know. |
Please see discussion here
You can take a look at the PR I made and you could reuse
Please also find the explanations why I closed my PR in mockery repository
The text was updated successfully, but these errors were encountered: