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

Logging warning when mock config is orphaned #764

Open
1 of 5 tasks
bentcoder opened this issue Mar 4, 2024 · 1 comment
Open
1 of 5 tasks

Logging warning when mock config is orphaned #764

bentcoder opened this issue Mar 4, 2024 · 1 comment
Labels
approved feature Feature request approved for development

Comments

@bentcoder
Copy link

Mockery Version

v2.42.0

Golang Version

go1.22.0 amd64

Installation Method

  • Binary Distribution
  • Docker
  • brew
  • go install
  • Other: [specify]

Steps to Reproduce

  1. Create an interface
  2. Add it to config file
  3. Run mockery to create mock
  4. Manually delete or comment out interface
  5. Rerun mockery command

Expected Behavior

Since interface doesn't exists anymore, I would have expected mockery command to error or something because there is a misleading/redundant reference in config.

Actual Behavior

Physical mock file is still in the codebase but unfortunately it is redundant because there is no interface for it anymore.

quiet: false
dir: "{{.InterfaceDir}}/mocks"
mockname: "{{.InterfaceName|camelcase}}"
filename: "{{.InterfaceName|snakecase}}.go"
outpkg: mocks

packages:
  github.com/myself/app/src/service:
    interfaces:
      MyInterface:

@LandonTClipp
Copy link
Contributor

LandonTClipp commented Mar 4, 2024

This should be very easy to add. Initially, we should only add a warning log to retain backwards compatibility. I'm approving this feature request to add a log. I do not want mockery to mutate the config, or delete old mock files, however. Removal of user's mocks should be the user's responsibility, as there are too many edge cases for mockery to handle it properly.

@LandonTClipp LandonTClipp added the approved feature Feature request approved for development label Mar 4, 2024
@LandonTClipp LandonTClipp changed the title Auto removing orphan mocks Logging warning when mock config is orphaned Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved feature Feature request approved for development
Projects
None yet
Development

No branches or pull requests

2 participants