Skip to content

Generate mocks for interfaces with generic types #173

@lucastorri

Description

@lucastorri

Hi!

I went through the existing issues and was not sure whether one specific to supporting interfaces with generic types exists. I had a look at #168, but this is about generating mocks for types which package uses generics.

In sum, I would like to have an interface such as:

//go:generate moq -stub -out publisher_mock.go . Publisher

type Publisher[M any] interface {
	Publish(ctx context.Context, msg M)
}

and be able to use a generic mock in my test:

publisher := PublisherMock[Something]{}

publisher.Publish(ctx, Something{})

Thank you!

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