check for field to be nil, not function - fixes #4

This commit is contained in:
Mat Ryer 2016-10-05 21:39:23 +01:00
parent b082cf0fd0
commit b050476316

View File

@ -217,7 +217,7 @@ type {{.InterfaceName}}Mock struct {
{{ range .Methods }}
// {{.Name}} calls {{.Name}}Func.
func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist}} {
if mock.{{.Name}} == nil {
if mock.{{.Name}}Func == nil {
panic("moq: {{.Name}}Func is nil but was just called")
}
return mock.{{.Name}}Func({{.ArgCallList}})