update the template to declare the input args as a struct type#54
Open
hcliff wants to merge 1 commit intomatryer:mainfrom
Open
update the template to declare the input args as a struct type#54hcliff wants to merge 1 commit intomatryer:mainfrom
hcliff wants to merge 1 commit intomatryer:mainfrom
Conversation
Author
|
any thoughts about this? would love to get it merged |
matryer
reviewed
Jul 24, 2018
| calls = mock.calls.{{.Name}} | ||
| lock{{$obj.InterfaceName}}Mock{{.Name}}.RUnlock() | ||
| return calls | ||
| defer lock{{$obj.InterfaceName}}Mock{{.Name}}.RUnlock() |
Owner
There was a problem hiding this comment.
Could we have this on two lines? I'm not a fan of compressing code onto one line at the cost of readability?
| {{ range .Methods }} | ||
|
|
||
| // {{.Name}}Call represents the input arguments to {{.Name}} | ||
| type {{.Name}}Call struct { |
Owner
There was a problem hiding this comment.
How much noise does this add to the API?
Owner
|
Hey @hcliff - thank you so much for this. I wonder if the additional types in the package space end up cluttering it too much? What do you think? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
instead of redefining a struct repeatedly create a type to declare the input args.
My motivation was to allow me to make assertions on this call in my tests (ginkgo/gomega in the example below) without needing to redeclare the struct myself
100% backwards compatible and actually results in less generated code