-
Notifications
You must be signed in to change notification settings - Fork 28
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
Ability to have a single mock implement multiple interfaces #81
Comments
Hey @jpopadak, very interesting use case. Have you worked around it so far by defining a interface along the lines of type IType12 interface {
IType1
IType2
} And generating the mock based on that or how did you work around it? From the top of my head I don't remember if the command you suggested is unambiguous, specifically because in the past you could generate multiple mocks by specifying multiple interfaces. Have you checked? |
I have not tried doing that, although that could work too. In my case, there were only 2 methods, one for each interface, so I created a stub struct with the implemented methods as needed. |
@jpopadak So I've checked the CLI: in theory it's possible to implement the command you suggested. However, I'm not convinced yet, that we should really add it: it will make the |
I honestly think the best route forward is the one you suggested here: #81 (comment) Might be useful in your documentation, but it's an obvious solution I didn't think about. 🙄 |
Agree, that could be part of the documentation. Let's leave this issue open and I'll see where it fits in best. (Will probably take a little longer this time as I'm a bit busy...) |
For some Go code, a single struct might implement multiple interfaces.
For example:
This helps with plug and play code, where you are accepting outside objects to execute logic on more than one interface.
Suggested generate command can be:
pegomock generate github.com/path/to/pkg IType1 github.com/path/to/other/pkg IType2
The text was updated successfully, but these errors were encountered: