diff --git a/package/moq/moq.go b/package/moq/moq.go index 83c5551..436579e 100644 --- a/package/moq/moq.go +++ b/package/moq/moq.go @@ -229,11 +229,12 @@ type {{.InterfaceName}}Mock struct { {{.Name}}Func func({{ .Arglist }}) {{.ReturnArglist}} {{- end }} } + {{ range .Methods }} // {{.Name}} calls {{.Name}}Func. func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist}} { if mock.{{.Name}}Func == nil { - panic("moq: {{.Name}}Func is nil but was just called") + panic("moq: {{$obj.InterfaceName}}Mock.{{.Name}}Func is nil but was just called") } return mock.{{.Name}}Func({{.ArgCallList}}) } diff --git a/package/moq/moq_test.go b/package/moq/moq_test.go index e69d4aa..b4dbf68 100644 --- a/package/moq/moq_test.go +++ b/package/moq/moq_test.go @@ -25,6 +25,8 @@ func TestMoq(t *testing.T) { "GetFunc func(ctx context.Context, id string) (*Person, error)", "func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm bool) error", "func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error)", + "panic(\"moq: PersonStoreMock.CreateFunc is nil but was just called\")", + "panic(\"moq: PersonStoreMock.GetFunc is nil but was just called\")", } for _, str := range strs { if !strings.Contains(s, str) {