Merge pull request #17 from matryer/remove-enabled

Remove enabled
This commit is contained in:
Mat Ryer 2017-07-07 20:09:14 +01:00 committed by GitHub
commit be1d7ca86c

View File

@ -265,12 +265,7 @@ type {{.InterfaceName}}Mock struct {
{{ end }}
// CallsTo tracks calls to the methods.
CallsTo struct {
// Enabled indicates that calls will be tracked.
//
// // don't track calls
// {{.InterfaceName}}Mock.CallsTo.Enabled = false
Enabled bool
{{ range .Methods }}
{{- range .Methods }}
lock{{.Name}} sync.Mutex // protects {{ .Name }}
// {{ .Name }} holds details about calls to the {{.Name}} method.
{{ .Name }} []struct {
@ -288,7 +283,6 @@ func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist
if mock.{{.Name}}Func == nil {
panic("moq: {{$obj.InterfaceName}}Mock.{{.Name}}Func is nil but was just called")
}
if mock.CallsTo.Enabled {
mock.CallsTo.lock{{.Name}}.Lock()
mock.CallsTo.{{.Name}} = append(mock.CallsTo.{{.Name}}, struct{
{{- range .Params }}
@ -300,7 +294,6 @@ func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist
{{- end }}
})
mock.CallsTo.lock{{.Name}}.Unlock()
}
{{- if .ReturnArglist }}
return mock.{{.Name}}Func({{.ArgCallList}})
{{- else }}