-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes type formatting in mock.gotmpl (#25)
* Adds the FormatType template function; fixes type formatting in default mock function setup
- Loading branch information
1 parent
9711b0b
commit ad80749
Showing
5 changed files
with
65 additions
and
14 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
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,45 @@ | ||
package generator | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func Test_FormatType_formats_parameter_type(t *testing.T) { | ||
// Arrange | ||
p := Parameter{IsArray: false, TypeName: "byte", Name: "data"} | ||
|
||
// Act | ||
actual := FormatType(p) | ||
|
||
// Assert | ||
assert.Equal(t, "byte", actual) | ||
} | ||
|
||
func Test_FormatType_formats_parameter_array_type(t *testing.T) { | ||
// Arrange | ||
p := Parameter{IsArray: true, TypeName: "byte", Name: "data"} | ||
|
||
// Act | ||
actual := FormatType(p) | ||
|
||
// Assert | ||
assert.Equal(t, "[]byte", actual) | ||
} | ||
|
||
func Test_FormattedParameters_formats_parameters(t *testing.T) { | ||
// Arrange | ||
p := Parameter{IsArray: true, TypeName: "byte", Name: "data"} | ||
|
||
method := Method{ | ||
Name: "Method0", | ||
Parameters: []Parameter{p, {Name: "msg", TypeName: "string", IsArray: false}}, | ||
Results: []Parameter{}, | ||
} | ||
|
||
// Act | ||
actual := FormattedParameters(method) | ||
|
||
// Assert | ||
assert.Equal(t, "data []byte, msg string", 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