-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for variadic functions
To make it useful, I also had to add support for unnamed parameters since that's fairly common when writing interfaces like this.
- Loading branch information
1 parent
7b5adb1
commit bb57a55
Showing
5 changed files
with
327 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ type Maths interface { | |
type Sender interface { | ||
SendMessage(title *string, message string) error | ||
SendMany(details map[string]string) error | ||
|
||
// Blocks the specified email address from being sent to. | ||
Block(string) error | ||
} | ||
|
||
type ArgumentMatchingTests struct { | ||
|
@@ -128,6 +131,18 @@ func (t *ArgumentMatchingTests) Test_CanMatchMaps() { | |
t.NoError(successResult) | ||
} | ||
|
||
func (t *ArgumentMatchingTests) Test_CanHandleNamelessParameters() { | ||
// Arrange | ||
mock := sender.NewMock() | ||
mock.Setup(sender.Block("[email protected]").Return(errors.New("cannot block that recipient!"))) | ||
|
||
// Act | ||
blockedResult := mock.Instance().Block("[email protected]") | ||
|
||
// Assert | ||
t.ErrorContains(blockedResult, "cannot block that recipient!") | ||
} | ||
|
||
func TestArgumentMatching(t *testing.T) { | ||
suite.Run(t, new(ArgumentMatchingTests)) | ||
} |
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
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