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: support types.Array as interface args #17

Merged
merged 1 commit into from
May 2, 2024

Conversation

tomMoulard
Copy link
Member

@tomMoulard tomMoulard commented May 2, 2024

This PR adds support for *types.Array.
Usefull when mocking an interface that look like this:

type Foo interface {
	Bar(a [][2]string)
}
Current mocktail output
> mocktail
panic: OOPS *types.Array [2]string

goroutine 1 [running]:
main.getTypeImports({0x7a2488?, 0xc0084c4378?})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:241 +0x374
main.getTypeImports({0x7a2190?, 0xc00b41e110?})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:214 +0x65
main.getTupleImports({0xc00a08f6e8, 0x2, 0xc00b41e850?})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:201 +0x131
main.getMethodImports(0xc008f903d0?, {0xc000170043, 0x3d})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:187 +0x77
main.walk.func1({0xc00015ea50, 0x4f}, {0x7a40c0, 0xc00010f5c0}, {0x0?, 0x0?})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:161 +0x947
path/filepath.walkDir({0xc00015ea50, 0x4f}, {0x7a40c0, 0xc00010f5c0}, 0xc00a08fdd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:443 +0x50
path/filepath.walkDir({0xc00015e870, 0x42}, {0x7a40c0, 0xc00010ed80}, 0xc00a08fdd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:465 +0x285
path/filepath.walkDir({0xc00001c700, 0x3b}, {0x7a40c0, 0xc00010ec80}, 0xc00a08fdd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:465 +0x285
path/filepath.walkDir({0xc00001a510, 0x30}, {0x7a40c0, 0xc00010e400}, 0xc00a08fdd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:465 +0x285
path/filepath.walkDir({0xc00001a300, 0x27}, {0x7a4088, 0xc000014220}, 0xc00a08fdd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:465 +0x285
path/filepath.WalkDir({0xc00001a300, 0x27}, 0xc000159dd8)
	/home/tm/.local/opt/go1.22.2/src/path/filepath/path.go:533 +0x7b
main.walk({0xc00001a300, 0x27}, {0xc00001a2d0, 0x22})
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:82 +0xe5
main.main()
	/home/tm/go/pkg/mod/github.com/traefik/mocktail@v0.5.1/mocktail.go:61 +0x232

@ldez ldez self-requested a review May 2, 2024 16:29
@ldez ldez added the kind/enhancement a new or improved feature. label May 2, 2024
Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@traefiker traefiker merged commit b49c602 into traefik:master May 2, 2024
7 checks passed
@tomMoulard tomMoulard deleted the feat/types-array branch May 2, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement a new or improved feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants