-
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.
Remove Update(). Now all params are updatable
- Loading branch information
Gabriel Gonzalez
committed
Sep 9, 2020
1 parent
3b7e8c6
commit 14c0a38
Showing
6 changed files
with
61 additions
and
23 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
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,13 @@ | ||
package wparam | ||
|
||
import "github.com/gbrlmza/gosmock" | ||
|
||
// The mocked implementation | ||
type MyStruct struct { | ||
gosmock.MockTool | ||
} | ||
|
||
func (s *MyStruct) AddItem(name *string, quantity *int, updatableParam *string) (p1 error) { | ||
s.GetMockedResponse(s.AddItem, name, quantity, updatableParam).Fill(&p1) | ||
return | ||
} |
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,30 @@ | ||
package wparam | ||
|
||
import ( | ||
"gotest.tools/assert" | ||
"testing" | ||
) | ||
|
||
func TestParam_AddItem(t *testing.T) { | ||
simple := &MyStruct{} | ||
|
||
num := 1 | ||
str1 := "str1" | ||
str2 := "str2" | ||
simple.Mock(simple.AddItem). | ||
WithParams(&str1, &num, &str2). | ||
WithParamUpdate(0, "newstr1"). | ||
WithParamUpdate(1, 2). | ||
WithParamUpdate(2, "newstr2"). | ||
WithResponse(nil). | ||
Times(1) | ||
|
||
err := simple.AddItem(&str1, &num, &str2) | ||
assert.NilError(t, err) | ||
assert.Equal(t, "newstr1", str1) | ||
assert.Equal(t, 2, num) | ||
assert.Equal(t, "newstr2", str2) | ||
|
||
// An extra check to ensure that all mocks were used | ||
assert.Equal(t, true, simple.AllMocksUsed()) | ||
} |
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