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

Fixing mockery infinitely generating its own interfaces #640

Merged
merged 1 commit into from
Jun 14, 2023
Merged

Fixing mockery infinitely generating its own interfaces #640

merged 1 commit into from
Jun 14, 2023

Conversation

LandonTClipp
Copy link
Contributor

@LandonTClipp LandonTClipp commented Jun 7, 2023

Description

Mockery currently will generate mocks for the interfaces it creates in its own auto-generated files. This is fixed by making the interface in-line in the function signature, which causes mockery to not attempt generating a mock for it.

TODO

Create integration test that asserts the number of files in the project over multiple mockery runs does not change.

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?

Added a new fixture and config in mockery to test the "in-package recursive" behavior. It was confirmed manually that mockery no longer generates mocks for its own interfaces.

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

@LandonTClipp LandonTClipp marked this pull request as ready for review June 13, 2023 22:16
@LandonTClipp LandonTClipp changed the title Issue 632 Fixing mockery infinitely generating its own interfaces Jun 13, 2023
@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Patch coverage: 100.00000% and project coverage change: -0.01085 ⚠️

Comparison is base (d667a59) 76.51131% compared to head (c77b9b7) 76.50046%.

❗ Current head c77b9b7 differs from pull request most recent head 7d5b1fc. Consider uploading reports for the commit 7d5b1fc to get more accurate results

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master        #640         +/-   ##
===================================================
- Coverage   76.51131%   76.50046%   -0.01085%     
===================================================
  Files              7           7                 
  Lines           2167        2166          -1     
===================================================
- Hits            1658        1657          -1     
  Misses           374         374                 
  Partials         135         135                 
Impacted Files Coverage Δ
pkg/generator.go 93.28947% <100.00000%> (-0.00883%) ⬇️

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

- Fixes #632
- Removing string comparison tests. These are not useful and are extremely burdensome.
- Regenerating mocks using new mock generation logic.

Renaming mocks, adding config for recursive generation

Adding a fixture for in-package recursive generation. I added config in
.mockery.yaml for this to test that mockery doesn't re-generate
interfaces it has created. I need to add an explicit integration test for
this.

Add end-to-end tests
@LandonTClipp LandonTClipp merged commit e85f2c0 into vektra:master Jun 14, 2023
5 checks passed
@LandonTClipp LandonTClipp deleted the issue_632 branch June 14, 2023 00:16
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.

Mockery generates mocks of auto-generated code when mocks are generated in-package.
1 participant