Skip to content

feat: add support for generic interfaces#33

Closed
tomMoulard wants to merge 5 commits into
traefik:masterfrom
tomMoulard:feat/generics
Closed

feat: add support for generic interfaces#33
tomMoulard wants to merge 5 commits into
traefik:masterfrom
tomMoulard:feat/generics

Conversation

@tomMoulard

Copy link
Copy Markdown
Contributor

This PR adds support for generic interfaces to be mocked.

Here is the basic example:

// interfaces.go
type Banana[T, U any] interface {
	Tree(T)
	Flower() U
	Pudding()
}

// mock_test.go

// mocktail:Banana

// interfaces_test.go
var b Banana[string, int] = newBananaMock[string, int](t).
	OnTree("a").Once().
	OnFlower().TypedReturns(1).Once().
	OnPudding().Once().
	Parent

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

Successfully merging this pull request may close these issues.

2 participants