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

feat: Allow generation of mocked interface that depends on other mocked interfaces from different packages #210

Open
juanli16 opened this issue Nov 20, 2023 · 1 comment

Comments

@juanli16
Copy link

juanli16 commented Nov 20, 2023

Please let me know if this is already supported, but I have tried to dig through the issues and PR and find nothing relating to this.

Basically, for the following example use case:

package client

//go:generate moq -out myclient_mock.go . Myclient
type MyClient interface {
    OtherClient() otherservice.Client
    AnotherClient() anotherservice.Client
    ... 
}

where MyClient is an interface that implements other interfaces from different packages, I would like the generated mocked MyClientMock to be able to call the mocked otherService.ClientMock and anotherService.ClientMock.

I can set it up like this to call the other mocked client:

func TestMyClient(t *testing.T) {
    myclient := &client.MyClientMock {
        OtherClient(): func() otherService.Client {
            return otherservice.ClientMock { ... }
        }
        ....
    }
}

But the call stack information for the other mocked clients are not available.

@scorpionknifes
Copy link

Found this #172 (comment)

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

No branches or pull requests

2 participants