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

Adding new KeepTree flag - allows to preserve tree struct for mocks #175

Merged
merged 2 commits into from
Aug 14, 2018

Conversation

corentone
Copy link
Contributor

  • Using the keeptree flag allows to generate mocks in a different
    directory but keeping the original structure of the repo that is being mocked.

  • Very useful for kubernetes client-go that has sometimes 3 versions of the
    same interface name hence requires different folders. Easiest way is to keep the
    same tree structure as if it was "inPlace".

  • KeepTree flag is most useful when used with -all, -dir and -output.

@corentone
Copy link
Contributor Author

I'm still testing it a bit more but would love to hear if this is something that could benefit more people.
It could use a bit more testing but I couldn't find much tests for the outputter logic.

* Using the keeptree flag allows to generate mocks in a different
directory but keeping the original structure of the repo that is being mocked.

* Very useful for kubernetes client-go that has sometimes 3 versions of the
same interface name hence requires different folders. Easiest way is to keep the
same tree structure as if it was "inPlace".

* KeepTree flag is most useful when used with -all, -dir and -output.
@corentone
Copy link
Contributor Author

@evanphx any opinion?

@corentone corentone mentioned this pull request Mar 23, 2018
@jybp
Copy link

jybp commented May 9, 2018

I have several interfaces with the same name causing a name conflict as described here:
#170

I tried using your branch with the keeptree flag but nothing changed, a single file was created under the mocks folder. I created a simple repository to reproduce the issue:
https://github.com/JyBP/keeptree

Is your PR supposed to fix those kind of conflicts as well?

@corentone
Copy link
Contributor Author

@jybp sorry for the delayed reply.

This worked for me:
https://gist.github.com/corentone/99a0d6f540a9afbe2c90f520ed08a8e6

KeepTree is good when you want to bulk generate all the mocks.
In your case, if you want to keep two separate commands, you may be able to use, from master:

mockery -name Dep -dir ./dep1  -output ./cmd/mocks/dep1
mockery -name Dep -dir ./dep2 -output ./cmd/mocks/dep2

@evanphx evanphx merged commit c65462c into vektra:master Aug 14, 2018
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Oct 19, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Oct 19, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Nov 20, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Nov 20, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Dec 23, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
LandonTClipp pushed a commit to LandonTClipp/mockery that referenced this pull request Dec 23, 2023
Allow the generation of mocks for generics as introduced in golang 1.18
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.

3 participants