-
Notifications
You must be signed in to change notification settings - Fork 412
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
Unable to generate interface type from another interface #787
Comments
Here is my
|
Hmm that's an interesting use case I have not thought of (generic interface with an instantiated type assigned to a different type name). It should work but I'm not sure what mockery thinks of this. Can you run with |
Hi @LandonTClipp, I got logs for |
If mockery did not print anything then something has gone wrong during its discovery phase of top-level interface definitions. I'll see if I can tinker with it. |
Well this is hilarious. The Go AST considers this to be an index expression: There's three ways we could resolve this:
PR: #790 |
Do you have any news about this issue ? I found related issues on other mock project if it can help you :
It seems to work with golang/mock but it's no longer maintained 🫤 |
No news about the issue... I don't know the best way to proceed other than bugging the Go devs to change the AST. How big of an issue is this for you? If it's preventing you from using this project, I can hack together a new parameter that will force generation in cases like these, but I'm miffed at the idea of adding yet another workaround. |
Hi @LandonTClipp, Yeah it prevent me to use this project but I see that you do a PR #790. |
Give me a few days and I will modify that PR to add a config parameter to turn on generation of these generic interfaces. The PR itself has compatibility issues and can't be merged as-is. |
So on second thought, I think this may indeed be simpler than what I was thinking. I was worried that including var array = []int{1, 2, 3}
var arrayElem = array[0] I was worried that References: |
Fixes issue vektra#787. Allow `*ast.IndexExpr` in a `*ast.TypeSpec` to be a mock target.
@FournyP give https://github.com/vektra/mockery/releases/tag/v2.44.1 a try and let me know if that works for you. |
I have the same issue, I am trying to create the mock for Mockery version: v2.44.2
|
Hi, we had a similar issue when trying to mock an inteface (from protoc-gen-go-grpc) that was migrated to use a generic one . e.g. of an interface that we are trying to mock:
|
This is a type alias of an instantiated generic interface. Type aliases are difficult to get right, although there is a fix in the works: #808
This should work? Can you share more details? Maybe post results of debug log? Can you give a minimal reproducer? |
@LandonTClipp sure, let me get something minimal to reproduce this issue. |
Hi so while writing the test steps I was able to make it work.
And previously I was using mockery to mock the |
Description
Hi, I wanted to write some mock for my interface :
But only the mock for
ResponseLessUseCase
was created, maybe I miss something ?Mockery Version
v2.43.2
Golang Version
v1.22.3
Installation Method
Steps to Reproduce
Expected Behavior
A mock for the interface that inherit the generic one
Actual Behavior
Only the mock of the generic interface
The text was updated successfully, but these errors were encountered: