vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
5.8k stars 395 forks source link

Fixes #769 : Mock files getting created in disk when dry-run is enabled #789

Closed snopan closed 4 days ago

snopan commented 5 days ago

Description

The PR aims to fix an issue with dry-run option when enabled is still creating the mock files in disk. There's an existing PR to resolve this but I can see it's been inactive since April so I thought to start another PR to resolve the comment. If this isn't okay please let me know, I'm still new to contributing to open source.

Type of change

Version of Golang used when building/testing:

How Has This Been Tested?

  1. Cleared the mocks by running task mocks.remove
  2. Added dry-run: True to mockery.yaml
  3. Ran task mocks which should only log and not create the files

Checklist

snopan commented 5 days ago

Hey @LandonTClipp, I saw the issue was inactive and I thought to give it a try hope it is okay. Feel free to have a review when you're free, thanks.

LandonTClipp commented 4 days ago

Looks like something is wrong, maybe dry-run is getting enabled in the tests when we didn't expect? I'll let you dig into it.

snopan commented 4 days ago

Yup so the original unit test had dryRun set to true while checking that files are created. Instead I've updated the tests to check dryRun as both true and false to confirm that files creation depend on that. I've also removed the wantError field from the test case as it's not used, is this common that fields are added but not used? If we need that there then I can add it back.

@LandonTClipp if I can get another review that would be great, thanks!