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

can't handle method/function signatures with variadicts #17

Open
shackra opened this issue Mar 21, 2024 · 0 comments
Open

can't handle method/function signatures with variadicts #17

shackra opened this issue Mar 21, 2024 · 0 comments

Comments

@shackra
Copy link
Contributor

shackra commented Mar 21, 2024

I've discovered that mockigo cannot handle methods or functions with variadict as arguments. I have a repository with code that demonstrates the bug:

https://github.com/shackra/mockigo-variadic-bug

if you run just run, you'll see that the example works as expected:

$ just run
go build -o mockigo-variadic-bug
./mockigo-variadic-bug
adding numbers for hello world...
hello world is 11

With just test you can run the tests.

However, in tests, we don't have any way to set an argument for a variadict argument, we have to use match.Any instead.

mock.EXPECT().
		Sum(match.AnyCtx(), match.Eq("test"), match.Any[int]()). // <- unable to use match.Arg[[]int]
		Return(18)

if we want to leave that argument empty, we get a different error:

$ just test
go test -covermode=count -coverprofile coverage ./...
--- FAIL: TestCalculator (0.00s)
    library.go:17: Unexpected call of method "Sum" because:
        expected call /tmp/example/library_test.go:15 expects 2 arguments, got 3
FAIL
        github.com/shackra/mockigo-variadic-bug coverage: 30.0% of statements
FAIL    github.com/shackra/mockigo-variadic-bug 0.002s
FAIL
error: Recipe `test` failed on line 2 with exit code 1
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

No branches or pull requests

1 participant