-
Notifications
You must be signed in to change notification settings - Fork 408
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 support for rolled variadics with expecter structs #629
Add support for rolled variadics with expecter structs #629
Conversation
unrolled-variadics=false
with expecter structs
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #629 +/- ##
===================================================
+ Coverage 76.25000% 76.29390% +0.04389%
===================================================
Files 7 7
Lines 2160 2164 +4
===================================================
+ Hits 1647 1651 +4
Misses 376 376
Partials 137 137
☔ View full report in Codecov by Sentry. |
87e7058
to
25091d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely the right direction, thank you very much. My only modification would be with the tests, described below.
return mock | ||
} | ||
` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to move away from the tests asserting the exact string of the generated mock as we currently have to modify like 40 different tests whenever the mock generation code changes. Instead, the better way to do this is add the mock with the specified config into the .mockery.yaml
file, and run tests off of that mock: https://github.com/vektra/mockery/blob/v2.27.1/.mockery.yaml#L17-L23
You'd need to add another section under the configs
of RequesterVariadic
, something like:
- mockname: RequesterVariadicExpecterAndUnrollVariadic
unroll-variadic: false
with-expected: true
It should be good enough for now to commit the mock and run the test. I'm going to implement a change to CI/CD so that it generates the mocks before running tests (it currently just generates them after).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted to follow this testing pattern. I also cleaned up other tests to use the require
interface and removed the incorrect messages.
@@ -59,7 +59,7 @@ func (s *GeneratorSuite) checkGenerationWithConfig( | |||
) *Generator { | |||
generator := s.getGeneratorWithConfig(filepath, interfaceName, cfg) | |||
err := generator.Generate(s.ctx) | |||
s.NoError(err, "The generator ran without errors.") | |||
s.Require().NoError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks for changing the tests.
Description
Adds support for
--unrolled-variadics=false
and--with-expecter
Followup from #624 (comment)
Type of change
Version of Golang used when building/testing:
How Has This Been Tested?
I have removed the test which asserted an error for this newly supported config and replaced with a test asserting the new functionality.
Checklist