improved nil panics to include service name
This commit is contained in:
parent
b76739db6c
commit
2ab8b1850c
@ -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}})
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user