Open shackra opened 7 months ago
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
$ 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.
just test
However, in tests, we don't have any way to set an argument for a variadict argument, we have to use match.Any instead.
match.Any
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
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: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.if we want to leave that argument empty, we get a different error: