-
Notifications
You must be signed in to change notification settings - Fork 412
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 #774 from LandonTClipp/issue_766
Fix bug when last argument is a function with multiple return values
- Loading branch information
Showing
6 changed files
with
136 additions
and
17 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
90 changes: 90 additions & 0 deletions
90
mocks/github.com/vektra/mockery/v2/pkg/fixtures/Issue766.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
package test | ||
|
||
type Issue766 interface { | ||
FetchData( | ||
fetchFunc func(x ...int) ([]int, error), | ||
) ([]int, 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,35 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
fixtures "github.com/vektra/mockery/v2/pkg/fixtures" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
mocks "github.com/vektra/mockery/v2/mocks/github.com/vektra/mockery/v2/pkg/fixtures" | ||
) | ||
|
||
// Asserts it implements the interface | ||
var _ fixtures.Issue766 = new(mocks.Issue766) | ||
|
||
func TestIssue766(t *testing.T) { | ||
fetchFunc := func(i ...int) ([]int, error) { | ||
ret := make([]int, 0, len(i)) | ||
for idx := 0; idx < len(i); idx++ { | ||
ret[idx] = i[idx] + 1 | ||
} | ||
return ret, nil | ||
} | ||
|
||
expected := []int{1, 2, 3} | ||
mockFetchData := mocks.NewIssue766(t) | ||
mockFetchData. | ||
EXPECT(). | ||
FetchData(mock.AnythingOfType("func(...int) ([]int, error)")). | ||
Return([]int{1, 2, 3}, nil) | ||
|
||
actual, err := mockFetchData.FetchData(fetchFunc) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expected, actual) | ||
} |
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