commit
be1d7ca86c
@ -264,13 +264,8 @@ type {{.InterfaceName}}Mock struct {
|
|||||||
{{.Name}}Func func({{ .Arglist }}) {{.ReturnArglist}}
|
{{.Name}}Func func({{ .Arglist }}) {{.ReturnArglist}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
// CallsTo tracks calls to the methods.
|
// CallsTo tracks calls to the methods.
|
||||||
CallsTo struct {
|
CallsTo struct {
|
||||||
// Enabled indicates that calls will be tracked.
|
{{- range .Methods }}
|
||||||
//
|
|
||||||
// // don't track calls
|
|
||||||
// {{.InterfaceName}}Mock.CallsTo.Enabled = false
|
|
||||||
Enabled bool
|
|
||||||
{{ range .Methods }}
|
|
||||||
lock{{.Name}} sync.Mutex // protects {{ .Name }}
|
lock{{.Name}} sync.Mutex // protects {{ .Name }}
|
||||||
// {{ .Name }} holds details about calls to the {{.Name}} method.
|
// {{ .Name }} holds details about calls to the {{.Name}} method.
|
||||||
{{ .Name }} []struct {
|
{{ .Name }} []struct {
|
||||||
@ -288,19 +283,17 @@ func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist
|
|||||||
if mock.{{.Name}}Func == nil {
|
if mock.{{.Name}}Func == nil {
|
||||||
panic("moq: {{$obj.InterfaceName}}Mock.{{.Name}}Func is nil but was just called")
|
panic("moq: {{$obj.InterfaceName}}Mock.{{.Name}}Func is nil but was just called")
|
||||||
}
|
}
|
||||||
if mock.CallsTo.Enabled {
|
mock.CallsTo.lock{{.Name}}.Lock()
|
||||||
mock.CallsTo.lock{{.Name}}.Lock()
|
mock.CallsTo.{{.Name}} = append(mock.CallsTo.{{.Name}}, struct{
|
||||||
mock.CallsTo.{{.Name}} = append(mock.CallsTo.{{.Name}}, struct{
|
{{- range .Params }}
|
||||||
{{- range .Params }}
|
{{ .Name | Exported }} {{ .Type }}
|
||||||
{{ .Name | Exported }} {{ .Type }}
|
{{- end }}
|
||||||
{{- end }}
|
}{
|
||||||
}{
|
{{- range .Params }}
|
||||||
{{- range .Params }}
|
{{ .Name | Exported }}: {{ .Name }},
|
||||||
{{ .Name | Exported }}: {{ .Name }},
|
{{- end }}
|
||||||
{{- end }}
|
})
|
||||||
})
|
mock.CallsTo.lock{{.Name}}.Unlock()
|
||||||
mock.CallsTo.lock{{.Name}}.Unlock()
|
|
||||||
}
|
|
||||||
{{- if .ReturnArglist }}
|
{{- if .ReturnArglist }}
|
||||||
return mock.{{.Name}}Func({{.ArgCallList}})
|
return mock.{{.Name}}Func({{.ArgCallList}})
|
||||||
{{- else }}
|
{{- else }}
|
||||||
|
Loading…
Reference in New Issue
Block a user