-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #719 from nicovak/nicovak/fix-707
Fixing mocks for interfaces where method returns function with variadic argument.
- Loading branch information
Showing
8 changed files
with
203 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
mocks "github.com/vektra/mockery/v2/mocks/github.com/vektra/mockery/v2/pkg/fixtures" | ||
) | ||
|
||
func TestVariadicReturnFunc(t *testing.T) { | ||
m := mocks.NewVariadicReturnFunc(t) | ||
m.EXPECT().SampleMethod("").Return(func(s string, l []int, a ...any) { | ||
assert.Equal(t, "foo", s) | ||
assert.Equal(t, []int{1, 2, 3}, l) | ||
assert.Equal(t, []any{"one", "two", "three"}, a) | ||
}) | ||
m.SampleMethod("")("foo", []int{1, 2, 3}, "one", "two", "three") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test | ||
|
||
type VariadicFunction = func(args1 string, args2 ...interface{}) interface{} | ||
|
||
type Variadic interface { | ||
VariadicFunction(str string, vFunc VariadicFunction) error | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test | ||
|
||
type VariadicReturnFunc interface { | ||
SampleMethod(str string) func(str string, arr []int, a ...interface{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters