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 support for rolled variadics with expecter structs #629

Conversation

dillonstreator
Copy link
Contributor

@dillonstreator dillonstreator commented May 23, 2023

Description

Adds support for --unrolled-variadics=false and --with-expecter

Followup from #624 (comment)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Version of Golang used when building/testing:

  • 1.11
  • 1.12
  • 1.13
  • 1.14
  • 1.15
  • 1.16
  • 1.17
  • 1.18
  • 1.19
  • 1.20

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

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@dillonstreator dillonstreator changed the title Add support for unrolled-variadics=false with expecter structs Add support for rolled variadics with expecter structs May 23, 2023
@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Patch coverage: 100.00000% and project coverage change: +0.04390 🎉

Comparison is base (b964d01) 76.25000% compared to head (ae9feff) 76.29390%.

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                 
Impacted Files Coverage Δ
pkg/generator.go 93.35938% <100.00000%> (+0.03476%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dillonstreator dillonstreator force-pushed the expecter-structs-with-rolled-variadics branch from 87e7058 to 25091d2 Compare May 23, 2023 00:46
Copy link
Contributor

@LandonTClipp LandonTClipp left a 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
}
`

Copy link
Contributor

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).

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Contributor

@LandonTClipp LandonTClipp left a 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.

@LandonTClipp LandonTClipp merged commit d0c93f6 into vektra:master May 23, 2023
5 checks passed
@jokly jokly mentioned this pull request Aug 30, 2023
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants