Skip to content

feat: add interface filtering support for mock generation with -interface flag#35

Closed
tomMoulard wants to merge 3 commits into
traefik:masterfrom
tomMoulard:feat/specifying-interface-cli
Closed

feat: add interface filtering support for mock generation with -interface flag#35
tomMoulard wants to merge 3 commits into
traefik:masterfrom
tomMoulard:feat/specifying-interface-cli

Conversation

@tomMoulard

@tomMoulard tomMoulard commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

This PR allows the filtering of generated interfaces when used in conjunction with the -source option.

This means that when generating mocks for a file, you can specify which interface you want to generate mocks on.

For example:

// file interfaces.go
type PiniaColada interface {
	Rhum() string
	Pine(apple string)
	Coconut()
}

type shirleyTemple interface {
	ale(ginger string)
	Grenadine()
	GetCherry() (maraschino string)
}

Running the following would only generate mocks for the PiniaColada interface.

mocktail -source interfaces.go -interface PiniaColada

Also note that the -interface can be provided with a comma (,) separated value to tell mocktail that you want to generate multiple mocks in a file.

Additional information

This PR fixes #9.

This PR is based on #33, and will need this PR to be approved/merged to do the same on this PR.

Thanks !

@tomMoulard tomMoulard closed this Jul 23, 2025
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.

Allow specifying interfaces to be mocked via mocktail argument (vs mock_test.go)

1 participant