Skip to content

Commit

Permalink
Fix mockery.templ
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Dec 30, 2024
1 parent c7fd6ba commit a90446c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/template/mockery.templ
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ func (_mock *{{$mock.MockName}}{{ $mock | TypeInstantiation }}) {{$method.Name}}
($method.IsVariadic)
(not (index $mock.TemplateData "unroll-variadic"))
}}

{{- if ne (len $method.Returns) 0}}
var tmpRet mock.Arguments
{{- $calledString = "tmpRet" }}
{{- else }}
{{- $calledString = "" }}
{{- end }}

{{- $lastParam := index $method.Params (len $method.Params | Add -1 )}}
if len({{ $lastParam.Var.Name }}) > 0 {
tmpRet = _mock.Called({{- if (index $mock.TemplateData "unroll-variadic") }}{{ $method.ArgCallList }}{{- else }}{{ $method.ArgCallListNoEllipsis }}{{- end }})
{{- if ne (len $method.Returns) 0}}tmpRet = {{ end }}_mock.Called({{- if (index $mock.TemplateData "unroll-variadic") }}{{ $method.ArgCallList }}{{- else }}{{ $method.ArgCallListNoEllipsis }}{{- end }})
} else {
tmpRet = _mock.Called({{- if (index $mock.TemplateData "unroll-variadic") }}{{ $method.ArgCallListSlice 0 (len $method.Params | Add -1 )}}{{- else }}{{ $method.ArgCallListSliceNoEllipsis 0 (len $method.Params | Add -1 )}}{{- end }})
{{- if ne (len $method.Returns) 0}}tmpRet = {{ end }}_mock.Called({{- if (index $mock.TemplateData "unroll-variadic") }}{{ $method.ArgCallListSlice 0 (len $method.Params | Add -1 )}}{{- else }}{{ $method.ArgCallListSliceNoEllipsis 0 (len $method.Params | Add -1 )}}{{- end }})
}
{{- $calledString = "tmpRet" }}
{{- else }}
{{- $calledString = printf "_mock.Called(%s)" $method.ArgCallList }}
{{- end }}
Expand Down

0 comments on commit a90446c

Please sign in to comment.