Skip to content

Commit

Permalink
feat: add support no return types on generate mock
Browse files Browse the repository at this point in the history
  • Loading branch information
akito0107 committed May 30, 2018
1 parent 40e6f1b commit 2bf1ee2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ func (g *Generator) appendMockStruct(it *InterfaceType) {
a = append(a, fmt.Sprintf("a%d", i))
}
}
g.Printf("return mk.%sMock(%s)\n", f.Name, strings.Join(a, ","))
if len(f.ReturnTypes) > 0 {
g.Printf("return ")
}
g.Printf("mk.%sMock(%s)\n", f.Name, strings.Join(a, ","))
g.Printf("}\n")
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func TestAppendMockStructMultipleFuncs(t *testing.T) {
}
func (mk *TestInterfaceMock) TestFunc1(a0 Arg1) {
return mk.TestFunc1Mock(a0)
mk.TestFunc1Mock(a0)
}
func (mk *TestInterfaceMock) TestFunc2(a0 Arg1, a1 Arg2) (Ret1, Ret2) {
return mk.TestFunc2Mock(a0, a1)
Expand Down Expand Up @@ -457,7 +457,7 @@ func TestAppendMockStructMultipleFuncWithPackages(t *testing.T) {
}
func (mk *TestInterfaceMock) TestFunc1(a0 pak1.Arg1) {
return mk.TestFunc1Mock(a0)
mk.TestFunc1Mock(a0)
}
func (mk *TestInterfaceMock) TestFunc2(a0 pak1.Arg1, a1 Arg2) (Ret1, pak2.Ret2) {
return mk.TestFunc2Mock(a0, a1)
Expand Down

0 comments on commit 2bf1ee2

Please sign in to comment.