Skip to content

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

Open
@juanli16

Description

@juanli16

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions