Skip to content

Commit

Permalink
feat: generates returnsFn on function without args
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Aug 29, 2022
1 parent e81c3a1 commit 3ec1844
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 4 deletions.
5 changes: 1 addition & 4 deletions syrup.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (s Syrup) mockedMethod(writer io.Writer) error {
}

func (s Syrup) writeReturnsFnCaller(w *Writer, argNames []string, params, results *types.Tuple) {
if len(argNames) > 0 && results.Len() > 0 {
if results.Len() > 0 {
w.Println()
w.Printf("\tif _rf, ok := _ret.Get(0).(%s); ok {\n", s.createFuncSignature(params, results))
w.Printf("\t\treturn _rf(%s", strings.Join(argNames, ", "))
Expand Down Expand Up @@ -453,9 +453,6 @@ func (s Syrup) returnsFn(writer io.Writer) error {
}

params := s.Signature.Params()
if params.Len() < 1 {
return nil
}

structBaseName := strcase.ToGoCamel(s.InterfaceName)

Expand Down
1 change: 1 addition & 0 deletions testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Pineapple interface {
World() string
Goo() (string, int, Water)
Coo(context.Context, string, Water) Water
Noo(context.Context) string
}

type Coconut interface {
Expand Down
172 changes: 172 additions & 0 deletions testdata/src/a/mock_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ec1844

Please sign in to comment.