matryer / moq

Interface mocking tool for go generate
http://bit.ly/meetmoq
MIT License
2k stars 127 forks source link

Allow aliasing interface name #57

Closed ruggi closed 5 years ago

ruggi commented 6 years ago

This PR allows to create an alias for a mocked interface, which doesn't necessarily match the original interface name.

The reason is that large projects often keep mocks in a single package, but when there's a naming overlap between multiple interfaces coming from different packages (i.e.: foo.Cache and bar.Cache) it can get a little tricky.

The idea here is to optionally allow to specify the interface name upon the moq command invocation with a colon : separating the actual interface name and the aliased name. For example:

moq -pkg=mocks foo/ Cache:FooCache
moq -pkg=mocks bar/ Cache:BarCache

which will generate FooCacheMock and BarCacheMock.

sudo-suhas commented 5 years ago

@matryer Would you be willing to accept a fresh PR with changes to support this feature? Relevant issue - #106

matryer commented 5 years ago

Yes, we can add this.

sudo-suhas commented 5 years ago

@matryer Please see #110