From e06c1576cf470233230245421681a1d16d3a2b22 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Tue, 2 Feb 2021 00:50:20 +0530 Subject: [PATCH 01/50] Internal registry for disambiguated imports, vars (#141) * Internal registry for disambiguated imports, vars - Move functionality in the moq package partially into internal/{registry,template}. - Leverage registry to assign unique package and variable/method parameter names. Use import aliases if present in interface source package. BREAKING CHANGE: When the interface definition does not mention the parameter names, the field names in call info anonymous struct will be different. The new field names are generated using the type info (string -> s, int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int -> stringToInt etc.). For example, for a string parameter previously if the field name was 'In1', the new field could be 'S' or 'S1' (depends on number of string method parameters). * Refactor golden file tests to be table-driven * Fix sync pkg alias handling for moq generation * Improve, add tests (increase coverage) * Use $.Foo in template, avoid declaring variables $ is set to the data argument passed to Execute, that is, to the starting value of dot. Variables were declared to be able to refer to the parent context. * Consistent template field formatting * Use tabs in generated Godoc comments' example code * Minor simplification * go generate * Fix conflict for generated param name of pointer type Excellent work by @sudo-suhas. --- internal/template/template.go | 190 +++++++++++++++++++++++++++++ internal/template/template_data.go | 125 +++++++++++++++++++ internal/template/template_test.go | 55 +++++++++ 3 files changed, 370 insertions(+) create mode 100644 internal/template/template.go create mode 100644 internal/template/template_data.go create mode 100644 internal/template/template_test.go diff --git a/internal/template/template.go b/internal/template/template.go new file mode 100644 index 00000000..22bb8e89 --- /dev/null +++ b/internal/template/template.go @@ -0,0 +1,190 @@ +package template + +import ( + "io" + "strings" + "text/template" + + "github.com/matryer/moq/internal/registry" +) + +// Template is the Moq template. It is capable of generating the Moq +// implementation for the given template.Data. +type Template struct { + tmpl *template.Template +} + +// New returns a new instance of Template. +func New() (Template, error) { + tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(moqTemplate) + if err != nil { + return Template{}, err + } + + return Template{tmpl: tmpl}, nil +} + +// Execute generates and writes the Moq implementation for the given +// data. +func (t Template) Execute(w io.Writer, data Data) error { + return t.tmpl.Execute(w, data) +} + +// moqTemplate is the template for mocked code. +// language=GoTemplate +var moqTemplate = `// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package {{.PkgName}} + +import ( +{{- range .Imports}} + {{. | ImportStatement}} +{{- end}} +) + +{{range $i, $mock := .Mocks -}} + +{{- if not $.SkipEnsure -}} +// Ensure, that {{.MockName}} does implement {{$.SrcPkgQualifier}}{{.InterfaceName}}. +// If this is not the case, regenerate this file with moq. +var _ {{$.SrcPkgQualifier}}{{.InterfaceName}} = &{{.MockName}}{} +{{- end}} + +// {{.MockName}} is a mock implementation of {{$.SrcPkgQualifier}}{{.InterfaceName}}. +// +// func TestSomethingThatUses{{.InterfaceName}}(t *testing.T) { +// +// // make and configure a mocked {{$.SrcPkgQualifier}}{{.InterfaceName}} +// mocked{{.InterfaceName}} := &{{.MockName}}{ + {{- range .Methods}} +// {{.Name}}Func: func({{.ArgList}}) {{.ReturnArgTypeList}} { +// panic("mock out the {{.Name}} method") +// }, + {{- end}} +// } +// +// // use mocked{{.InterfaceName}} in code that requires {{$.SrcPkgQualifier}}{{.InterfaceName}} +// // and then make assertions. +// +// } +type {{.MockName}} struct { +{{- range .Methods}} + // {{.Name}}Func mocks the {{.Name}} method. + {{.Name}}Func func({{.ArgList}}) {{.ReturnArgTypeList}} +{{end}} + // calls tracks calls to the methods. + calls struct { +{{- range .Methods}} + // {{.Name}} holds details about calls to the {{.Name}} method. + {{.Name}} []struct { + {{- range .Params}} + // {{.Name | Exported}} is the {{.Name}} argument value. + {{.Name | Exported}} {{.TypeString}} + {{- end}} + } +{{- end}} + } +{{- range .Methods}} + lock{{.Name}} {{$.Imports | SyncPkgQualifier}}.RWMutex +{{- end}} +} +{{range .Methods}} +// {{.Name}} calls {{.Name}}Func. +func (mock *{{$mock.MockName}}) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { +{{- if not $.StubImpl}} + if mock.{{.Name}}Func == nil { + panic("{{$mock.MockName}}.{{.Name}}Func: method is nil but {{$mock.InterfaceName}}.{{.Name}} was just called") + } +{{- end}} + callInfo := struct { + {{- range .Params}} + {{.Name | Exported}} {{.TypeString}} + {{- end}} + }{ + {{- range .Params}} + {{.Name | Exported}}: {{.Name}}, + {{- end}} + } + mock.lock{{.Name}}.Lock() + mock.calls.{{.Name}} = append(mock.calls.{{.Name}}, callInfo) + mock.lock{{.Name}}.Unlock() +{{- if .Returns}} + {{- if $.StubImpl}} + if mock.{{.Name}}Func == nil { + var ( + {{- range .Returns}} + {{.Name}} {{.TypeString}} + {{- end}} + ) + return {{.ReturnArgNameList}} + } + {{- end}} + return mock.{{.Name}}Func({{.ArgCallList}}) +{{- else}} + {{- if $.StubImpl}} + if mock.{{.Name}}Func == nil { + return + } + {{- end}} + mock.{{.Name}}Func({{.ArgCallList}}) +{{- end}} +} + +// {{.Name}}Calls gets all the calls that were made to {{.Name}}. +// Check the length with: +// len(mocked{{$mock.InterfaceName}}.{{.Name}}Calls()) +func (mock *{{$mock.MockName}}) {{.Name}}Calls() []struct { + {{- range .Params}} + {{.Name | Exported}} {{.TypeString}} + {{- end}} + } { + var calls []struct { + {{- range .Params}} + {{.Name | Exported}} {{.TypeString}} + {{- end}} + } + mock.lock{{.Name}}.RLock() + calls = mock.calls.{{.Name}} + mock.lock{{.Name}}.RUnlock() + return calls +} +{{end -}} +{{end -}}` + +// This list comes from the golint codebase. Golint will complain about any of +// these being mixed-case, like "Id" instead of "ID". +var golintInitialisms = []string{ + "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "LHS", + "QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "UID", "UUID", "URI", + "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", +} + +var templateFuncs = template.FuncMap{ + "ImportStatement": func(imprt *registry.Package) string { + if imprt.Alias == "" { + return `"` + imprt.Path() + `"` + } + return imprt.Alias + ` "` + imprt.Path() + `"` + }, + "SyncPkgQualifier": func(imports []*registry.Package) string { + for _, imprt := range imports { + if imprt.Path() == "sync" { + return imprt.Qualifier() + } + } + + return "sync" + }, + "Exported": func(s string) string { + if s == "" { + return "" + } + for _, initialism := range golintInitialisms { + if strings.ToUpper(s) == initialism { + return initialism + } + } + return strings.ToUpper(s[0:1]) + s[1:] + }, +} diff --git a/internal/template/template_data.go b/internal/template/template_data.go new file mode 100644 index 00000000..0a95bb5e --- /dev/null +++ b/internal/template/template_data.go @@ -0,0 +1,125 @@ +package template + +import ( + "fmt" + "strings" + + "github.com/matryer/moq/internal/registry" +) + +// Data is the template data used to render the Moq template. +type Data struct { + PkgName string + SrcPkgQualifier string + Imports []*registry.Package + Mocks []MockData + StubImpl bool + SkipEnsure bool +} + +// MocksSomeMethod returns true of any one of the Mocks has at least 1 +// method. +func (d Data) MocksSomeMethod() bool { + for _, m := range d.Mocks { + if len(m.Methods) > 0 { + return true + } + } + + return false +} + +// MockData is the data used to generate a mock for some interface. +type MockData struct { + InterfaceName string + MockName string + Methods []MethodData +} + +// MethodData is the data which represents a method on some interface. +type MethodData struct { + Name string + Params []ParamData + Returns []ParamData +} + +// ArgList is the string representation of method parameters, ex: +// 's string, n int, foo bar.Baz'. +func (m MethodData) ArgList() string { + params := make([]string, len(m.Params)) + for i, p := range m.Params { + params[i] = p.MethodArg() + } + return strings.Join(params, ", ") +} + +// ArgCallList is the string representation of method call parameters, +// ex: 's, n, foo'. In case of a last variadic parameter, it will be of +// the format 's, n, foos...' +func (m MethodData) ArgCallList() string { + params := make([]string, len(m.Params)) + for i, p := range m.Params { + params[i] = p.CallName() + } + return strings.Join(params, ", ") +} + +// ReturnArgTypeList is the string representation of method return +// types, ex: 'bar.Baz', '(string, error)'. +func (m MethodData) ReturnArgTypeList() string { + params := make([]string, len(m.Returns)) + for i, p := range m.Returns { + params[i] = p.TypeString() + } + if len(m.Returns) > 1 { + return fmt.Sprintf("(%s)", strings.Join(params, ", ")) + } + return strings.Join(params, ", ") +} + +// ReturnArgNameList is the string representation of values being +// returned from the method, ex: 'foo', 's, err'. +func (m MethodData) ReturnArgNameList() string { + params := make([]string, len(m.Returns)) + for i, p := range m.Returns { + params[i] = p.Name() + } + return strings.Join(params, ", ") +} + +// ParamData is the data which represents a parameter to some method of +// an interface. +type ParamData struct { + Var *registry.Var + Variadic bool +} + +// Name returns the name of the parameter. +func (p ParamData) Name() string { + return p.Var.Name +} + +// MethodArg is the representation of the parameter in the function +// signature, ex: 'name a.Type'. +func (p ParamData) MethodArg() string { + if p.Variadic { + return fmt.Sprintf("%s ...%s", p.Name(), p.TypeString()[2:]) + } + return fmt.Sprintf("%s %s", p.Name(), p.TypeString()) +} + +// CallName returns the string representation of the parameter to be +// used for a method call. For a variadic paramter, it will be of the +// format 'foos...'. +func (p ParamData) CallName() string { + if p.Variadic { + return p.Name() + "..." + } + return p.Name() +} + +// TypeString returns the string representation of the type of the +// parameter. +func (p ParamData) TypeString() string { + return p.Var.TypeString() +} diff --git a/internal/template/template_test.go b/internal/template/template_test.go new file mode 100644 index 00000000..e977d48c --- /dev/null +++ b/internal/template/template_test.go @@ -0,0 +1,55 @@ +package template + +import ( + "go/types" + "testing" + + "github.com/matryer/moq/internal/registry" +) + +func TestTemplateFuncs(t *testing.T) { + t.Run("Exported", func(t *testing.T) { + f := templateFuncs["Exported"].(func(string) string) + if f("") != "" { + t.Errorf("Exported(...) want: ``; got: `%s`", f("")) + } + if f("var") != "Var" { + t.Errorf("Exported(...) want: `Var`; got: `%s`", f("var")) + } + }) + + t.Run("ImportStatement", func(t *testing.T) { + f := templateFuncs["ImportStatement"].(func(*registry.Package) string) + pkg := registry.NewPackage(types.NewPackage("xyz", "xyz")) + if f(pkg) != `"xyz"` { + t.Errorf("ImportStatement(...): want: `\"xyz\"`; got: `%s`", f(pkg)) + } + + pkg.Alias = "x" + if f(pkg) != `x "xyz"` { + t.Errorf("ImportStatement(...): want: `x \"xyz\"`; got: `%s`", f(pkg)) + } + }) + + t.Run("SyncPkgQualifier", func(t *testing.T) { + f := templateFuncs["SyncPkgQualifier"].(func([]*registry.Package) string) + if f(nil) != "sync" { + t.Errorf("SyncPkgQualifier(...): want: `sync`; got: `%s`", f(nil)) + } + imports := []*registry.Package{ + registry.NewPackage(types.NewPackage("sync", "sync")), + registry.NewPackage(types.NewPackage("github.com/some/module", "module")), + } + if f(imports) != "sync" { + t.Errorf("SyncPkgQualifier(...): want: `sync`; got: `%s`", f(imports)) + } + + syncPkg := registry.NewPackage(types.NewPackage("sync", "sync")) + syncPkg.Alias = "stdsync" + otherSyncPkg := registry.NewPackage(types.NewPackage("github.com/someother/sync", "sync")) + imports = []*registry.Package{otherSyncPkg, syncPkg} + if f(imports) != "stdsync" { + t.Errorf("SyncPkgQualifier(...): want: `stdsync`; got: `%s`", f(imports)) + } + }) +} From 36a85cee92c217a0e7db0c1e9671c5a9e7ffd779 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Sat, 1 Oct 2022 04:38:16 -0400 Subject: [PATCH 02/50] feat: support generic interface generation (#175) Allow the generation of mocks for generics as introduced in golang 1.18 --- internal/template/template.go | 40 +++++++++++++++++++++++++++--- internal/template/template_data.go | 7 ++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/internal/template/template.go b/internal/template/template.go index 22bb8e89..9d7cd066 100644 --- a/internal/template/template.go +++ b/internal/template/template.go @@ -48,7 +48,22 @@ import ( {{- if not $.SkipEnsure -}} // Ensure, that {{.MockName}} does implement {{$.SrcPkgQualifier}}{{.InterfaceName}}. // If this is not the case, regenerate this file with moq. -var _ {{$.SrcPkgQualifier}}{{.InterfaceName}} = &{{.MockName}}{} +var _ {{$.SrcPkgQualifier}}{{.InterfaceName -}} + {{- if .TypeParams }}[ + {{- range $index, $param := .TypeParams}} + {{- if $index}}, {{end -}} + {{if $param.Constraint}}{{$param.Constraint.String}}{{else}}{{$param.TypeString}}{{end}} + {{- end -}} + ] + {{- end }} = &{{.MockName}} + {{- if .TypeParams }}[ + {{- range $index, $param := .TypeParams}} + {{- if $index}}, {{end -}} + {{if $param.Constraint}}{{$param.Constraint.String}}{{else}}{{$param.TypeString}}{{end}} + {{- end -}} + ] + {{- end -}} +{} {{- end}} // {{.MockName}} is a mock implementation of {{$.SrcPkgQualifier}}{{.InterfaceName}}. @@ -68,7 +83,12 @@ var _ {{$.SrcPkgQualifier}}{{.InterfaceName}} = &{{.MockName}}{} // // and then make assertions. // // } -type {{.MockName}} struct { +type {{.MockName}} +{{- if .TypeParams -}} + [{{- range $index, $param := .TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} {{$param.TypeString}} + {{- end -}}] +{{- end }} struct { {{- range .Methods}} // {{.Name}}Func mocks the {{.Name}} method. {{.Name}}Func func({{.ArgList}}) {{.ReturnArgTypeList}} @@ -91,7 +111,13 @@ type {{.MockName}} struct { } {{range .Methods}} // {{.Name}} calls {{.Name}}Func. -func (mock *{{$mock.MockName}}) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { +func (mock *{{$mock.MockName}} +{{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] +{{- end -}} +) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { {{- if not $.StubImpl}} if mock.{{.Name}}Func == nil { panic("{{$mock.MockName}}.{{.Name}}Func: method is nil but {{$mock.InterfaceName}}.{{.Name}} was just called") @@ -134,7 +160,13 @@ func (mock *{{$mock.MockName}}) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { // {{.Name}}Calls gets all the calls that were made to {{.Name}}. // Check the length with: // len(mocked{{$mock.InterfaceName}}.{{.Name}}Calls()) -func (mock *{{$mock.MockName}}) {{.Name}}Calls() []struct { +func (mock *{{$mock.MockName}} +{{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] +{{- end -}} +) {{.Name}}Calls() []struct { {{- range .Params}} {{.Name | Exported}} {{.TypeString}} {{- end}} diff --git a/internal/template/template_data.go b/internal/template/template_data.go index 0a95bb5e..12c91174 100644 --- a/internal/template/template_data.go +++ b/internal/template/template_data.go @@ -2,6 +2,7 @@ package template import ( "fmt" + "go/types" "strings" "github.com/matryer/moq/internal/registry" @@ -33,6 +34,7 @@ func (d Data) MocksSomeMethod() bool { type MockData struct { InterfaceName string MockName string + TypeParams []TypeParamData Methods []MethodData } @@ -87,6 +89,11 @@ func (m MethodData) ReturnArgNameList() string { return strings.Join(params, ", ") } +type TypeParamData struct { + ParamData + Constraint types.Type +} + // ParamData is the data which represents a parameter to some method of // an interface. type ParamData struct { From d1b2fd4efa1914e72cb7186d6ab1402c04f40d8d Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Sun, 13 Nov 2022 11:44:08 +0530 Subject: [PATCH 03/50] Go version independent moq output with consistent whitespace By tweaking whitespace in template --- internal/template/template.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/template/template.go b/internal/template/template.go index 9d7cd066..8412ab92 100644 --- a/internal/template/template.go +++ b/internal/template/template.go @@ -68,21 +68,21 @@ var _ {{$.SrcPkgQualifier}}{{.InterfaceName -}} // {{.MockName}} is a mock implementation of {{$.SrcPkgQualifier}}{{.InterfaceName}}. // -// func TestSomethingThatUses{{.InterfaceName}}(t *testing.T) { +// func TestSomethingThatUses{{.InterfaceName}}(t *testing.T) { // -// // make and configure a mocked {{$.SrcPkgQualifier}}{{.InterfaceName}} -// mocked{{.InterfaceName}} := &{{.MockName}}{ +// // make and configure a mocked {{$.SrcPkgQualifier}}{{.InterfaceName}} +// mocked{{.InterfaceName}} := &{{.MockName}}{ {{- range .Methods}} -// {{.Name}}Func: func({{.ArgList}}) {{.ReturnArgTypeList}} { -// panic("mock out the {{.Name}} method") -// }, +// {{.Name}}Func: func({{.ArgList}}) {{.ReturnArgTypeList}} { +// panic("mock out the {{.Name}} method") +// }, {{- end}} -// } +// } // -// // use mocked{{.InterfaceName}} in code that requires {{$.SrcPkgQualifier}}{{.InterfaceName}} -// // and then make assertions. +// // use mocked{{.InterfaceName}} in code that requires {{$.SrcPkgQualifier}}{{.InterfaceName}} +// // and then make assertions. // -// } +// } type {{.MockName}} {{- if .TypeParams -}} [{{- range $index, $param := .TypeParams}} @@ -159,7 +159,8 @@ func (mock *{{$mock.MockName}} // {{.Name}}Calls gets all the calls that were made to {{.Name}}. // Check the length with: -// len(mocked{{$mock.InterfaceName}}.{{.Name}}Calls()) +// +// len(mocked{{$mock.InterfaceName}}.{{.Name}}Calls()) func (mock *{{$mock.MockName}} {{- if $mock.TypeParams -}} [{{- range $index, $param := $mock.TypeParams}} From d411b1501e2d41cd33378dc26ae9c37c882b0ca2 Mon Sep 17 00:00:00 2001 From: Chad Date: Wed, 8 Mar 2023 00:28:51 -0500 Subject: [PATCH 04/50] Add flag to enable mock reset methods (#181) The optional with-resets flag adds methods to reset method calls. Calls can be reset individually or all at once with these. --- internal/template/template.go | 21 ++++++++++++++++++++- internal/template/template_data.go | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/internal/template/template.go b/internal/template/template.go index 8412ab92..9e2672cc 100644 --- a/internal/template/template.go +++ b/internal/template/template.go @@ -182,8 +182,27 @@ func (mock *{{$mock.MockName}} mock.lock{{.Name}}.RUnlock() return calls } +{{- if $.WithResets}} +// Reset{{.Name}}Calls reset all the calls that were made to {{.Name}}. +func (mock *{{$mock.MockName}}) Reset{{.Name}}Calls() { + mock.lock{{.Name}}.Lock() + mock.calls.{{.Name}} = nil + mock.lock{{.Name}}.Unlock() +} +{{end}} +{{end -}} +{{- if $.WithResets}} +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *{{$mock.MockName}}) ResetCalls() { + {{- range .Methods}} + mock.lock{{.Name}}.Lock() + mock.calls.{{.Name}} = nil + mock.lock{{.Name}}.Unlock() + {{end -}} +} +{{end -}} {{end -}} -{{end -}}` +` // This list comes from the golint codebase. Golint will complain about any of // these being mixed-case, like "Id" instead of "ID". diff --git a/internal/template/template_data.go b/internal/template/template_data.go index 12c91174..2a3caeba 100644 --- a/internal/template/template_data.go +++ b/internal/template/template_data.go @@ -16,6 +16,7 @@ type Data struct { Mocks []MockData StubImpl bool SkipEnsure bool + WithResets bool } // MocksSomeMethod returns true of any one of the Mocks has at least 1 From 0028a347abf8ee9a90e27e89b3de0868fd35e63c Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Thu, 19 Oct 2023 13:56:44 -0500 Subject: [PATCH 05/50] updates --- .../template.go => pkg/template/moq.templ | 74 +------------------ pkg/template/template.go | 45 +++++++++++ {internal => pkg}/template/template_data.go | 0 {internal => pkg}/template/template_test.go | 0 4 files changed, 46 insertions(+), 73 deletions(-) rename internal/template/template.go => pkg/template/moq.templ (70%) create mode 100644 pkg/template/template.go rename {internal => pkg}/template/template_data.go (100%) rename {internal => pkg}/template/template_test.go (100%) diff --git a/internal/template/template.go b/pkg/template/moq.templ similarity index 70% rename from internal/template/template.go rename to pkg/template/moq.templ index 9e2672cc..b3d3dc32 100644 --- a/internal/template/template.go +++ b/pkg/template/moq.templ @@ -1,38 +1,4 @@ -package template - -import ( - "io" - "strings" - "text/template" - - "github.com/matryer/moq/internal/registry" -) - -// Template is the Moq template. It is capable of generating the Moq -// implementation for the given template.Data. -type Template struct { - tmpl *template.Template -} - -// New returns a new instance of Template. -func New() (Template, error) { - tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(moqTemplate) - if err != nil { - return Template{}, err - } - - return Template{tmpl: tmpl}, nil -} - -// Execute generates and writes the Moq implementation for the given -// data. -func (t Template) Execute(w io.Writer, data Data) error { - return t.tmpl.Execute(w, data) -} - -// moqTemplate is the template for mocked code. -// language=GoTemplate -var moqTemplate = `// Code generated by moq; DO NOT EDIT. +// Code generated by moq; DO NOT EDIT. // github.com/matryer/moq package {{.PkgName}} @@ -202,41 +168,3 @@ func (mock *{{$mock.MockName}}) ResetCalls() { } {{end -}} {{end -}} -` - -// This list comes from the golint codebase. Golint will complain about any of -// these being mixed-case, like "Id" instead of "ID". -var golintInitialisms = []string{ - "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "LHS", - "QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "UID", "UUID", "URI", - "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", -} - -var templateFuncs = template.FuncMap{ - "ImportStatement": func(imprt *registry.Package) string { - if imprt.Alias == "" { - return `"` + imprt.Path() + `"` - } - return imprt.Alias + ` "` + imprt.Path() + `"` - }, - "SyncPkgQualifier": func(imports []*registry.Package) string { - for _, imprt := range imports { - if imprt.Path() == "sync" { - return imprt.Qualifier() - } - } - - return "sync" - }, - "Exported": func(s string) string { - if s == "" { - return "" - } - for _, initialism := range golintInitialisms { - if strings.ToUpper(s) == initialism { - return initialism - } - } - return strings.ToUpper(s[0:1]) + s[1:] - }, -} diff --git a/pkg/template/template.go b/pkg/template/template.go new file mode 100644 index 00000000..1622101c --- /dev/null +++ b/pkg/template/template.go @@ -0,0 +1,45 @@ +package template + +import ( + "io" + "text/template" +) + +// Template is the Moq template. It is capable of generating the Moq +// implementation for the given template.Data. +type Template struct { + tmpl *template.Template +} + +//go:embed moq.templ +var moqTemplate string + +var styleMap = map[string]string{ + "moq": moqTemplate, +} + +// New returns a new instance of Template. +func New(style string) (Template, error) { + tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(styleMap[style]) + if err != nil { + return Template{}, err + } + + return Template{tmpl: tmpl}, nil +} + +// Execute generates and writes the Moq implementation for the given +// data. +func (t Template) Execute(w io.Writer, data Data) error { + return t.tmpl.Execute(w, data) +} + +// This list comes from the golint codebase. Golint will complain about any of +// these being mixed-case, like "Id" instead of "ID". +var golintInitialisms = []string{ + "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "LHS", + "QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "UID", "UUID", "URI", + "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", +} + +var templateFuncs = template.FuncMap{} diff --git a/internal/template/template_data.go b/pkg/template/template_data.go similarity index 100% rename from internal/template/template_data.go rename to pkg/template/template_data.go diff --git a/internal/template/template_test.go b/pkg/template/template_test.go similarity index 100% rename from internal/template/template_test.go rename to pkg/template/template_test.go From d16ef1bb36911f93ba89d62aa46e06ed3526f7a4 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Tue, 2 Feb 2021 00:50:20 +0530 Subject: [PATCH 06/50] Internal registry for disambiguated imports, vars (#141) * Internal registry for disambiguated imports, vars - Move functionality in the moq package partially into internal/{registry,template}. - Leverage registry to assign unique package and variable/method parameter names. Use import aliases if present in interface source package. BREAKING CHANGE: When the interface definition does not mention the parameter names, the field names in call info anonymous struct will be different. The new field names are generated using the type info (string -> s, int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int -> stringToInt etc.). For example, for a string parameter previously if the field name was 'In1', the new field could be 'S' or 'S1' (depends on number of string method parameters). * Refactor golden file tests to be table-driven * Fix sync pkg alias handling for moq generation * Improve, add tests (increase coverage) * Use $.Foo in template, avoid declaring variables $ is set to the data argument passed to Execute, that is, to the starting value of dot. Variables were declared to be able to refer to the parent context. * Consistent template field formatting * Use tabs in generated Godoc comments' example code * Minor simplification * go generate * Fix conflict for generated param name of pointer type Excellent work by @sudo-suhas. --- internal/registry/method_scope.go | 155 ++++++++++++++++++++++++ internal/registry/package.go | 93 +++++++++++++++ internal/registry/registry.go | 190 ++++++++++++++++++++++++++++++ internal/registry/var.go | 123 +++++++++++++++++++ 4 files changed, 561 insertions(+) create mode 100644 internal/registry/method_scope.go create mode 100644 internal/registry/package.go create mode 100644 internal/registry/registry.go create mode 100644 internal/registry/var.go diff --git a/internal/registry/method_scope.go b/internal/registry/method_scope.go new file mode 100644 index 00000000..59cc3128 --- /dev/null +++ b/internal/registry/method_scope.go @@ -0,0 +1,155 @@ +package registry + +import ( + "go/types" + "strconv" +) + +// MethodScope is the sub-registry for allocating variables present in +// the method scope. +// +// It should be created using a registry instance. +type MethodScope struct { + registry *Registry + moqPkgPath string + + vars []*Var + conflicted map[string]bool +} + +// AddVar allocates a variable instance and adds it to the method scope. +// +// Variables names are generated if required and are ensured to be +// without conflict with other variables and imported packages. It also +// adds the relevant imports to the registry for each added variable. +func (m *MethodScope) AddVar(vr *types.Var, suffix string) *Var { + name := vr.Name() + if name == "" || name == "_" { + name = generateVarName(vr.Type()) + } + + name += suffix + + switch name { + case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", + "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", + "import", "return", "var": + name += "MoqParam" + } + + if _, ok := m.searchVar(name); ok || m.conflicted[name] { + return m.addDisambiguatedVar(vr, name) + } + + return m.addVar(vr, name) +} + +func (m *MethodScope) addDisambiguatedVar(vr *types.Var, suggested string) *Var { + n := 1 + for { + // Keep incrementing the suffix until we find a name which is unused. + if _, ok := m.searchVar(suggested + strconv.Itoa(n)); !ok { + break + } + n++ + } + + name := suggested + strconv.Itoa(n) + if n == 1 { + conflict, _ := m.searchVar(suggested) + conflict.Name += "1" + name = suggested + "2" + m.conflicted[suggested] = true + } + + return m.addVar(vr, name) +} + +func (m *MethodScope) addVar(vr *types.Var, name string) *Var { + imports := make(map[string]*Package) + m.populateImports(vr.Type(), imports) + + v := Var{ + vr: vr, + imports: imports, + moqPkgPath: m.moqPkgPath, + Name: name, + } + m.vars = append(m.vars, &v) + m.resolveImportVarConflicts(&v) + return &v +} + +func (m MethodScope) searchVar(name string) (*Var, bool) { + for _, v := range m.vars { + if v.Name == name { + return v, true + } + } + + return nil, false +} + +// populateImports extracts all the package imports for a given type +// recursively. The imported packages by a single type can be more than +// one (ex: map[a.Type]b.Type). +func (m MethodScope) populateImports(t types.Type, imports map[string]*Package) { + switch t := t.(type) { + case *types.Named: + if pkg := t.Obj().Pkg(); pkg != nil { + imports[stripVendorPath(pkg.Path())] = m.registry.AddImport(pkg) + } + + case *types.Array: + m.populateImports(t.Elem(), imports) + + case *types.Slice: + m.populateImports(t.Elem(), imports) + + case *types.Signature: + for i := 0; i < t.Params().Len(); i++ { + m.populateImports(t.Params().At(i).Type(), imports) + } + for i := 0; i < t.Results().Len(); i++ { + m.populateImports(t.Results().At(i).Type(), imports) + } + + case *types.Map: + m.populateImports(t.Key(), imports) + m.populateImports(t.Elem(), imports) + + case *types.Chan: + m.populateImports(t.Elem(), imports) + + case *types.Pointer: + m.populateImports(t.Elem(), imports) + + case *types.Struct: // anonymous struct + for i := 0; i < t.NumFields(); i++ { + m.populateImports(t.Field(i).Type(), imports) + } + + case *types.Interface: // anonymous interface + for i := 0; i < t.NumExplicitMethods(); i++ { + m.populateImports(t.ExplicitMethod(i).Type(), imports) + } + for i := 0; i < t.NumEmbeddeds(); i++ { + m.populateImports(t.EmbeddedType(i), imports) + } + } +} + +func (m MethodScope) resolveImportVarConflicts(v *Var) { + // Ensure that the newly added var does not conflict with a package import + // which was added earlier. + if _, ok := m.registry.searchImport(v.Name); ok { + v.Name += "MoqParam" + } + // Ensure that all the newly added imports do not conflict with any of the + // existing vars. + for _, imprt := range v.imports { + if v, ok := m.searchVar(imprt.Qualifier()); ok { + v.Name += "MoqParam" + } + } +} diff --git a/internal/registry/package.go b/internal/registry/package.go new file mode 100644 index 00000000..37682424 --- /dev/null +++ b/internal/registry/package.go @@ -0,0 +1,93 @@ +package registry + +import ( + "go/types" + "path" + "strings" +) + +// Package represents an imported package. +type Package struct { + pkg *types.Package + + Alias string +} + +// NewPackage creates a new instance of Package. +func NewPackage(pkg *types.Package) *Package { return &Package{pkg: pkg} } + +// Qualifier returns the qualifier which must be used to refer to types +// declared in the package. +func (p *Package) Qualifier() string { + if p == nil { + return "" + } + + if p.Alias != "" { + return p.Alias + } + + return p.pkg.Name() +} + +// Path is the full package import path (without vendor). +func (p *Package) Path() string { + if p == nil { + return "" + } + + return stripVendorPath(p.pkg.Path()) +} + +var replacer = strings.NewReplacer( + "go-", "", + "-go", "", + "-", "", + "_", "", + ".", "", + "@", "", + "+", "", + "~", "", +) + +// uniqueName generates a unique name for a package by concatenating +// path components. The generated name is guaranteed to unique with an +// appropriate level because the full package import paths themselves +// are unique. +func (p Package) uniqueName(lvl int) string { + pp := strings.Split(p.Path(), "/") + reverse(pp) + + var name string + for i := 0; i < min(len(pp), lvl+1); i++ { + name = strings.ToLower(replacer.Replace(pp[i])) + name + } + + return name +} + +// stripVendorPath strips the vendor dir prefix from a package path. +// For example we might encounter an absolute path like +// github.com/foo/bar/vendor/github.com/pkg/errors which is resolved +// to github.com/pkg/errors. +func stripVendorPath(p string) string { + parts := strings.Split(p, "/vendor/") + if len(parts) == 1 { + return p + } + return strings.TrimLeft(path.Join(parts[1:]...), "/") +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func reverse(a []string) { + for i := len(a)/2 - 1; i >= 0; i-- { + opp := len(a) - 1 - i + a[i], a[opp] = a[opp], a[i] + } +} diff --git a/internal/registry/registry.go b/internal/registry/registry.go new file mode 100644 index 00000000..e0171832 --- /dev/null +++ b/internal/registry/registry.go @@ -0,0 +1,190 @@ +package registry + +import ( + "errors" + "fmt" + "go/types" + "path/filepath" + "sort" + "strings" + + "golang.org/x/tools/go/packages" +) + +// Registry encapsulates types information for the source and mock +// destination package. For the mock package, it tracks the list of +// imports and ensures there are no conflicts in the imported package +// qualifiers. +type Registry struct { + srcPkg *packages.Package + moqPkgPath string + aliases map[string]string + imports map[string]*Package +} + +// New loads the source package info and returns a new instance of +// Registry. +func New(srcDir, moqPkg string) (*Registry, error) { + srcPkg, err := pkgInfoFromPath( + srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes|packages.NeedTypesInfo, + ) + if err != nil { + return nil, fmt.Errorf("couldn't load source package: %s", err) + } + + return &Registry{ + srcPkg: srcPkg, + moqPkgPath: findPkgPath(moqPkg, srcPkg), + aliases: parseImportsAliases(srcPkg), + imports: make(map[string]*Package), + }, nil +} + +// SrcPkg returns the types info for the source package. +func (r Registry) SrcPkg() *types.Package { + return r.srcPkg.Types +} + +// SrcPkgName returns the name of the source package. +func (r Registry) SrcPkgName() string { + return r.srcPkg.Name +} + +// LookupInterface returns the underlying interface definition of the +// given interface name. +func (r Registry) LookupInterface(name string) (*types.Interface, error) { + obj := r.SrcPkg().Scope().Lookup(name) + if obj == nil { + return nil, fmt.Errorf("interface not found: %s", name) + } + + if !types.IsInterface(obj.Type()) { + return nil, fmt.Errorf("%s (%s) is not an interface", name, obj.Type()) + } + + return obj.Type().Underlying().(*types.Interface).Complete(), nil +} + +// MethodScope returns a new MethodScope. +func (r *Registry) MethodScope() *MethodScope { + return &MethodScope{ + registry: r, + moqPkgPath: r.moqPkgPath, + conflicted: map[string]bool{}, + } +} + +// AddImport adds the given package to the set of imports. It generates a +// suitable alias if there are any conflicts with previously imported +// packages. +func (r *Registry) AddImport(pkg *types.Package) *Package { + path := stripVendorPath(pkg.Path()) + if path == r.moqPkgPath { + return nil + } + + if imprt, ok := r.imports[path]; ok { + return imprt + } + + imprt := Package{pkg: pkg, Alias: r.aliases[path]} + + if conflict, ok := r.searchImport(imprt.Qualifier()); ok { + resolveImportConflict(&imprt, conflict, 0) + } + + r.imports[path] = &imprt + return &imprt +} + +// Imports returns the list of imported packages. The list is sorted by +// path. +func (r Registry) Imports() []*Package { + imports := make([]*Package, 0, len(r.imports)) + for _, imprt := range r.imports { + imports = append(imports, imprt) + } + sort.Slice(imports, func(i, j int) bool { + return imports[i].Path() < imports[j].Path() + }) + return imports +} + +func (r Registry) searchImport(name string) (*Package, bool) { + for _, imprt := range r.imports { + if imprt.Qualifier() == name { + return imprt, true + } + } + + return nil, false +} + +func pkgInfoFromPath(srcDir string, mode packages.LoadMode) (*packages.Package, error) { + pkgs, err := packages.Load(&packages.Config{ + Mode: mode, + Dir: srcDir, + }) + if err != nil { + return nil, err + } + if len(pkgs) == 0 { + return nil, errors.New("package not found") + } + if len(pkgs) > 1 { + return nil, errors.New("found more than one package") + } + if errs := pkgs[0].Errors; len(errs) != 0 { + if len(errs) == 1 { + return nil, errs[0] + } + return nil, fmt.Errorf("%s (and %d more errors)", errs[0], len(errs)-1) + } + return pkgs[0], nil +} + +func findPkgPath(pkgInputVal string, srcPkg *packages.Package) string { + if pkgInputVal == "" { + return srcPkg.PkgPath + } + if pkgInDir(srcPkg.PkgPath, pkgInputVal) { + return srcPkg.PkgPath + } + subdirectoryPath := filepath.Join(srcPkg.PkgPath, pkgInputVal) + if pkgInDir(subdirectoryPath, pkgInputVal) { + return subdirectoryPath + } + return "" +} + +func pkgInDir(pkgName, dir string) bool { + currentPkg, err := pkgInfoFromPath(dir, packages.NeedName) + if err != nil { + return false + } + return currentPkg.Name == pkgName || currentPkg.Name+"_test" == pkgName +} + +func parseImportsAliases(pkg *packages.Package) map[string]string { + aliases := make(map[string]string) + for _, syntax := range pkg.Syntax { + for _, imprt := range syntax.Imports { + if imprt.Name != nil && imprt.Name.Name != "." { + aliases[strings.Trim(imprt.Path.Value, `"`)] = imprt.Name.Name + } + } + } + return aliases +} + +// resolveImportConflict generates and assigns a unique alias for +// packages with conflicting qualifiers. +func resolveImportConflict(a, b *Package, lvl int) { + u1, u2 := a.uniqueName(lvl), b.uniqueName(lvl) + if u1 != u2 { + a.Alias, b.Alias = u1, u2 + return + } + + resolveImportConflict(a, b, lvl+1) +} diff --git a/internal/registry/var.go b/internal/registry/var.go new file mode 100644 index 00000000..f3117355 --- /dev/null +++ b/internal/registry/var.go @@ -0,0 +1,123 @@ +package registry + +import ( + "go/types" + "strings" +) + +// Var represents a method variable/parameter. +// +// It should be created using a method scope instance. +type Var struct { + vr *types.Var + imports map[string]*Package + moqPkgPath string + + Name string +} + +// IsSlice returns whether the type (or the underlying type) is a slice. +func (v Var) IsSlice() bool { + _, ok := v.vr.Type().Underlying().(*types.Slice) + return ok +} + +// TypeString returns the variable type with the package qualifier in the +// format 'pkg.Type'. +func (v Var) TypeString() string { + return types.TypeString(v.vr.Type(), v.packageQualifier) +} + +// packageQualifier is a types.Qualifier. +func (v Var) packageQualifier(pkg *types.Package) string { + path := stripVendorPath(pkg.Path()) + if v.moqPkgPath != "" && v.moqPkgPath == path { + return "" + } + + return v.imports[path].Qualifier() +} + +// generateVarName generates a name for the variable using the type +// information. +// +// Examples: +// - string -> s +// - int -> n +// - chan int -> intCh +// - []a.MyType -> myTypes +// - map[string]int -> stringToInt +// - error -> err +// - a.MyType -> myType +func generateVarName(t types.Type) string { + nestedType := func(t types.Type) string { + if t, ok := t.(*types.Basic); ok { + return deCapitalise(t.String()) + } + return generateVarName(t) + } + + switch t := t.(type) { + case *types.Named: + if t.Obj().Name() == "error" { + return "err" + } + + name := deCapitalise(t.Obj().Name()) + if name == t.Obj().Name() { + name += "MoqParam" + } + + return name + + case *types.Basic: + return basicTypeVarName(t) + + case *types.Array: + return nestedType(t.Elem()) + "s" + + case *types.Slice: + return nestedType(t.Elem()) + "s" + + case *types.Struct: // anonymous struct + return "val" + + case *types.Pointer: + return generateVarName(t.Elem()) + + case *types.Signature: + return "fn" + + case *types.Interface: // anonymous interface + return "ifaceVal" + + case *types.Map: + return nestedType(t.Key()) + "To" + capitalise(nestedType(t.Elem())) + + case *types.Chan: + return nestedType(t.Elem()) + "Ch" + } + + return "v" +} + +func basicTypeVarName(b *types.Basic) string { + switch b.Info() { + case types.IsBoolean: + return "b" + + case types.IsInteger: + return "n" + + case types.IsFloat: + return "f" + + case types.IsString: + return "s" + } + + return "v" +} + +func capitalise(s string) string { return strings.ToUpper(s[:1]) + s[1:] } +func deCapitalise(s string) string { return strings.ToLower(s[:1]) + s[1:] } From 5ea7cdaa4f7da83a6b887e12b7bddb992385064d Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Sun, 14 Feb 2021 18:40:16 +0530 Subject: [PATCH 07/50] Fix var name generation to avoid conflict (#145) When the type and the package name is the same for an anonymous parameter (ex: time.Time), and there are more than 1 such parameters, the generated name for both was the same. And the generated code would not be valid. Fix the bug by ensuring the parameter name does not conflict with package imports first before checking against other parameter names. --- internal/registry/method_scope.go | 76 ++++++++++++------------------- internal/registry/var.go | 26 +++++++++-- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/internal/registry/method_scope.go b/internal/registry/method_scope.go index 59cc3128..cf6ca253 100644 --- a/internal/registry/method_scope.go +++ b/internal/registry/method_scope.go @@ -23,52 +23,19 @@ type MethodScope struct { // without conflict with other variables and imported packages. It also // adds the relevant imports to the registry for each added variable. func (m *MethodScope) AddVar(vr *types.Var, suffix string) *Var { - name := vr.Name() - if name == "" || name == "_" { - name = generateVarName(vr.Type()) - } - - name += suffix + imports := make(map[string]*Package) + m.populateImports(vr.Type(), imports) + m.resolveImportVarConflicts(imports) - switch name { - case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", - "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", - "import", "return", "var": + name := varName(vr, suffix) + // Ensure that the var name does not conflict with a package import. + if _, ok := m.registry.searchImport(name); ok { name += "MoqParam" } - if _, ok := m.searchVar(name); ok || m.conflicted[name] { - return m.addDisambiguatedVar(vr, name) - } - - return m.addVar(vr, name) -} - -func (m *MethodScope) addDisambiguatedVar(vr *types.Var, suggested string) *Var { - n := 1 - for { - // Keep incrementing the suffix until we find a name which is unused. - if _, ok := m.searchVar(suggested + strconv.Itoa(n)); !ok { - break - } - n++ - } - - name := suggested + strconv.Itoa(n) - if n == 1 { - conflict, _ := m.searchVar(suggested) - conflict.Name += "1" - name = suggested + "2" - m.conflicted[suggested] = true + name = m.resolveVarNameConflict(name) } - return m.addVar(vr, name) -} - -func (m *MethodScope) addVar(vr *types.Var, name string) *Var { - imports := make(map[string]*Package) - m.populateImports(vr.Type(), imports) - v := Var{ vr: vr, imports: imports, @@ -76,10 +43,26 @@ func (m *MethodScope) addVar(vr *types.Var, name string) *Var { Name: name, } m.vars = append(m.vars, &v) - m.resolveImportVarConflicts(&v) return &v } +func (m *MethodScope) resolveVarNameConflict(suggested string) string { + for n := 1; ; n++ { + _, ok := m.searchVar(suggested + strconv.Itoa(n)) + if ok { + continue + } + + if n == 1 { + conflict, _ := m.searchVar(suggested) + conflict.Name += "1" + m.conflicted[suggested] = true + n++ + } + return suggested + strconv.Itoa(n) + } +} + func (m MethodScope) searchVar(name string) (*Var, bool) { for _, v := range m.vars { if v.Name == name { @@ -139,15 +122,12 @@ func (m MethodScope) populateImports(t types.Type, imports map[string]*Package) } } -func (m MethodScope) resolveImportVarConflicts(v *Var) { - // Ensure that the newly added var does not conflict with a package import - // which was added earlier. - if _, ok := m.registry.searchImport(v.Name); ok { - v.Name += "MoqParam" - } +// resolveImportVarConflicts ensures that all the newly added imports do not +// conflict with any of the existing vars. +func (m MethodScope) resolveImportVarConflicts(imports map[string]*Package) { // Ensure that all the newly added imports do not conflict with any of the // existing vars. - for _, imprt := range v.imports { + for _, imprt := range imports { if v, ok := m.searchVar(imprt.Qualifier()); ok { v.Name += "MoqParam" } diff --git a/internal/registry/var.go b/internal/registry/var.go index f3117355..abb0d53b 100644 --- a/internal/registry/var.go +++ b/internal/registry/var.go @@ -38,7 +38,25 @@ func (v Var) packageQualifier(pkg *types.Package) string { return v.imports[path].Qualifier() } -// generateVarName generates a name for the variable using the type +func varName(vr *types.Var, suffix string) string { + name := vr.Name() + if name != "" && name != "_" { + return name + suffix + } + + name = varNameForType(vr.Type()) + suffix + + switch name { + case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", + "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", + "import", "return", "var": + name += "MoqParam" + } + + return name +} + +// varNameForType generates a name for the variable using the type // information. // // Examples: @@ -49,12 +67,12 @@ func (v Var) packageQualifier(pkg *types.Package) string { // - map[string]int -> stringToInt // - error -> err // - a.MyType -> myType -func generateVarName(t types.Type) string { +func varNameForType(t types.Type) string { nestedType := func(t types.Type) string { if t, ok := t.(*types.Basic); ok { return deCapitalise(t.String()) } - return generateVarName(t) + return varNameForType(t) } switch t := t.(type) { @@ -83,7 +101,7 @@ func generateVarName(t types.Type) string { return "val" case *types.Pointer: - return generateVarName(t.Elem()) + return varNameForType(t.Elem()) case *types.Signature: return "fn" From 2c9d05c4a0576a573fa7870283cdf7f45acd1883 Mon Sep 17 00:00:00 2001 From: Ben Atkinson <42865129+maneac@users.noreply.github.com> Date: Sun, 4 Jul 2021 04:01:46 +0100 Subject: [PATCH 08/50] Ignore anonymous imports when resolving import aliases (#150) --- internal/registry/registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index e0171832..714cdd99 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -169,7 +169,7 @@ func parseImportsAliases(pkg *packages.Package) map[string]string { aliases := make(map[string]string) for _, syntax := range pkg.Syntax { for _, imprt := range syntax.Imports { - if imprt.Name != nil && imprt.Name.Name != "." { + if imprt.Name != nil && imprt.Name.Name != "." && imprt.Name.Name != "_" { aliases[strings.Trim(imprt.Path.Value, `"`)] = imprt.Name.Name } } From 9e0e5d0f25f3bd1b3d5029f0defe1854b4e35567 Mon Sep 17 00:00:00 2001 From: dedalusj Date: Sat, 18 Dec 2021 14:26:01 +1100 Subject: [PATCH 09/50] Fix issue with custom types shadowing basic types (#163) When a custom type has a name that can shadow an in-built type, append MoqParam to the name. Example: var name stringMoqParam for null.String. --- internal/registry/var.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/registry/var.go b/internal/registry/var.go index abb0d53b..081a17c7 100644 --- a/internal/registry/var.go +++ b/internal/registry/var.go @@ -49,7 +49,12 @@ func varName(vr *types.Var, suffix string) string { switch name { case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", - "import", "return", "var": + "import", "return", "var", + // avoid shadowing basic types + "string", "bool", "byte", "rune", "uintptr", + "int", "int8", "int16", "int32", "int64", + "uint", "uint8", "uint16", "uint32", "uint64", + "float32", "float64", "complex64", "complex128": name += "MoqParam" } From 92a6e93ead13dcb3e80f9dc68a8e90943f7e4a7e Mon Sep 17 00:00:00 2001 From: metalrex100 Date: Tue, 29 Mar 2022 19:12:08 +0300 Subject: [PATCH 10/50] Added packages.NeedDeps bit to packages.LoadMode to fix error (#171) --- internal/registry/registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 714cdd99..0c923e9b 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -26,7 +26,7 @@ type Registry struct { // Registry. func New(srcDir, moqPkg string) (*Registry, error) { srcPkg, err := pkgInfoFromPath( - srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes|packages.NeedTypesInfo, + srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes|packages.NeedTypesInfo|packages.NeedDeps, ) if err != nil { return nil, fmt.Errorf("couldn't load source package: %s", err) From 4468afa3faf717363d5c2f2d82b9ca92f4bbfc73 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Sat, 1 Oct 2022 04:38:16 -0400 Subject: [PATCH 11/50] feat: support generic interface generation (#175) Allow the generation of mocks for generics as introduced in golang 1.18 --- internal/registry/registry.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 0c923e9b..ca0f1aa9 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -52,17 +52,23 @@ func (r Registry) SrcPkgName() string { // LookupInterface returns the underlying interface definition of the // given interface name. -func (r Registry) LookupInterface(name string) (*types.Interface, error) { +func (r Registry) LookupInterface(name string) (*types.Interface, *types.TypeParamList, error) { obj := r.SrcPkg().Scope().Lookup(name) if obj == nil { - return nil, fmt.Errorf("interface not found: %s", name) + return nil, nil, fmt.Errorf("interface not found: %s", name) } if !types.IsInterface(obj.Type()) { - return nil, fmt.Errorf("%s (%s) is not an interface", name, obj.Type()) + return nil, nil, fmt.Errorf("%s (%s) is not an interface", name, obj.Type()) } - return obj.Type().Underlying().(*types.Interface).Complete(), nil + var tparams *types.TypeParamList + named, ok := obj.Type().(*types.Named) + if ok { + tparams = named.TypeParams() + } + + return obj.Type().Underlying().(*types.Interface).Complete(), tparams, nil } // MethodScope returns a new MethodScope. From fb12cf9e0f98efa7158232de613f668339852d40 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Sun, 13 Nov 2022 12:45:16 +0530 Subject: [PATCH 12/50] Recursively check unique pkg names against existing imports When we generate a unique name for pkg a on conflict with pkg b, the new name could already be in use for pkg c. So recursively check each unique name against existing imports before setting it. --- internal/registry/registry.go | 38 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index ca0f1aa9..4109c883 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -96,7 +96,7 @@ func (r *Registry) AddImport(pkg *types.Package) *Package { imprt := Package{pkg: pkg, Alias: r.aliases[path]} if conflict, ok := r.searchImport(imprt.Qualifier()); ok { - resolveImportConflict(&imprt, conflict, 0) + r.resolveImportConflict(&imprt, conflict, 0) } r.imports[path] = &imprt @@ -126,6 +126,30 @@ func (r Registry) searchImport(name string) (*Package, bool) { return nil, false } +// resolveImportConflict generates and assigns a unique alias for +// packages with conflicting qualifiers. +func (r Registry) resolveImportConflict(a, b *Package, lvl int) { + if a.uniqueName(lvl) == b.uniqueName(lvl) { + r.resolveImportConflict(a, b, lvl+1) + return + } + + for _, p := range []*Package{a, b} { + name := p.uniqueName(lvl) + // Even though the name is not conflicting with the other package we + // got, the new name we want to pick might already be taken. So check + // again for conflicts and resolve them as well. Since the name for + // this package would also get set in the recursive function call, skip + // setting the alias after it. + if conflict, ok := r.searchImport(name); ok && conflict != p { + r.resolveImportConflict(p, conflict, lvl+1) + continue + } + + p.Alias = name + } +} + func pkgInfoFromPath(srcDir string, mode packages.LoadMode) (*packages.Package, error) { pkgs, err := packages.Load(&packages.Config{ Mode: mode, @@ -182,15 +206,3 @@ func parseImportsAliases(pkg *packages.Package) map[string]string { } return aliases } - -// resolveImportConflict generates and assigns a unique alias for -// packages with conflicting qualifiers. -func resolveImportConflict(a, b *Package, lvl int) { - u1, u2 := a.uniqueName(lvl), b.uniqueName(lvl) - if u1 != u2 { - a.Alias, b.Alias = u1, u2 - return - } - - resolveImportConflict(a, b, lvl+1) -} From ebe7652ca1eb245d5e4e63da8028997ece95b909 Mon Sep 17 00:00:00 2001 From: Tim van Osch Date: Wed, 21 Jun 2023 11:01:30 +0200 Subject: [PATCH 13/50] Add imports for Named Type's type arguments (#199) --- internal/registry/method_scope.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/registry/method_scope.go b/internal/registry/method_scope.go index cf6ca253..65b56162 100644 --- a/internal/registry/method_scope.go +++ b/internal/registry/method_scope.go @@ -82,6 +82,13 @@ func (m MethodScope) populateImports(t types.Type, imports map[string]*Package) if pkg := t.Obj().Pkg(); pkg != nil { imports[stripVendorPath(pkg.Path())] = m.registry.AddImport(pkg) } + // The imports of a Type with a TypeList must be added to the imports list + // For example: Foo[otherpackage.Bar] , must have otherpackage imported + if targs := t.TypeArgs(); targs != nil { + for i := 0; i < targs.Len(); i++ { + m.populateImports(targs.At(i), imports) + } + } case *types.Array: m.populateImports(t.Elem(), imports) From 222a8a9b0c93aacf5dd718430526bbaadaead266 Mon Sep 17 00:00:00 2001 From: Sam Herrmann Date: Sun, 13 Aug 2023 05:16:10 -0400 Subject: [PATCH 14/50] Do not load unnecessary package information (#203) - Add benchmark test for registry.New --- internal/registry/registry.go | 39 ++++++++++++++++-------------- internal/registry/registry_test.go | 13 ++++++++++ 2 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 internal/registry/registry_test.go diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 4109c883..a237cdce 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -3,6 +3,7 @@ package registry import ( "errors" "fmt" + "go/ast" "go/types" "path/filepath" "sort" @@ -16,38 +17,40 @@ import ( // imports and ensures there are no conflicts in the imported package // qualifiers. type Registry struct { - srcPkg *packages.Package - moqPkgPath string - aliases map[string]string - imports map[string]*Package + srcPkgName string + srcPkgTypes *types.Package + moqPkgPath string + aliases map[string]string + imports map[string]*Package } // New loads the source package info and returns a new instance of // Registry. func New(srcDir, moqPkg string) (*Registry, error) { srcPkg, err := pkgInfoFromPath( - srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes|packages.NeedTypesInfo|packages.NeedDeps, + srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes, ) if err != nil { return nil, fmt.Errorf("couldn't load source package: %s", err) } return &Registry{ - srcPkg: srcPkg, - moqPkgPath: findPkgPath(moqPkg, srcPkg), - aliases: parseImportsAliases(srcPkg), - imports: make(map[string]*Package), + srcPkgName: srcPkg.Name, + srcPkgTypes: srcPkg.Types, + moqPkgPath: findPkgPath(moqPkg, srcPkg.PkgPath), + aliases: parseImportsAliases(srcPkg.Syntax), + imports: make(map[string]*Package), }, nil } // SrcPkg returns the types info for the source package. func (r Registry) SrcPkg() *types.Package { - return r.srcPkg.Types + return r.srcPkgTypes } // SrcPkgName returns the name of the source package. func (r Registry) SrcPkgName() string { - return r.srcPkg.Name + return r.srcPkgName } // LookupInterface returns the underlying interface definition of the @@ -173,14 +176,14 @@ func pkgInfoFromPath(srcDir string, mode packages.LoadMode) (*packages.Package, return pkgs[0], nil } -func findPkgPath(pkgInputVal string, srcPkg *packages.Package) string { +func findPkgPath(pkgInputVal string, srcPkgPath string) string { if pkgInputVal == "" { - return srcPkg.PkgPath + return srcPkgPath } - if pkgInDir(srcPkg.PkgPath, pkgInputVal) { - return srcPkg.PkgPath + if pkgInDir(srcPkgPath, pkgInputVal) { + return srcPkgPath } - subdirectoryPath := filepath.Join(srcPkg.PkgPath, pkgInputVal) + subdirectoryPath := filepath.Join(srcPkgPath, pkgInputVal) if pkgInDir(subdirectoryPath, pkgInputVal) { return subdirectoryPath } @@ -195,9 +198,9 @@ func pkgInDir(pkgName, dir string) bool { return currentPkg.Name == pkgName || currentPkg.Name+"_test" == pkgName } -func parseImportsAliases(pkg *packages.Package) map[string]string { +func parseImportsAliases(syntaxTree []*ast.File) map[string]string { aliases := make(map[string]string) - for _, syntax := range pkg.Syntax { + for _, syntax := range syntaxTree { for _, imprt := range syntax.Imports { if imprt.Name != nil && imprt.Name.Name != "." && imprt.Name.Name != "_" { aliases[strings.Trim(imprt.Path.Value, `"`)] = imprt.Name.Name diff --git a/internal/registry/registry_test.go b/internal/registry/registry_test.go new file mode 100644 index 00000000..38011c6d --- /dev/null +++ b/internal/registry/registry_test.go @@ -0,0 +1,13 @@ +package registry_test + +import ( + "testing" + + "github.com/matryer/moq/internal/registry" +) + +func BenchmarkNew(b *testing.B) { + for i := 0; i < b.N; i++ { + registry.New("../../pkg/moq/testpackages/example", "") + } +} From 1d04e7d92ae0e92abcd8315bf7181ae09b4d2929 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Thu, 19 Oct 2023 14:01:48 -0500 Subject: [PATCH 15/50] Add registry package from moq --- {internal => pkg}/registry/method_scope.go | 0 {internal => pkg}/registry/package.go | 0 {internal => pkg}/registry/registry.go | 0 {internal => pkg}/registry/registry_test.go | 0 {internal => pkg}/registry/var.go | 0 pkg/template/template_data.go | 2 +- pkg/template/template_test.go | 2 +- 7 files changed, 2 insertions(+), 2 deletions(-) rename {internal => pkg}/registry/method_scope.go (100%) rename {internal => pkg}/registry/package.go (100%) rename {internal => pkg}/registry/registry.go (100%) rename {internal => pkg}/registry/registry_test.go (100%) rename {internal => pkg}/registry/var.go (100%) diff --git a/internal/registry/method_scope.go b/pkg/registry/method_scope.go similarity index 100% rename from internal/registry/method_scope.go rename to pkg/registry/method_scope.go diff --git a/internal/registry/package.go b/pkg/registry/package.go similarity index 100% rename from internal/registry/package.go rename to pkg/registry/package.go diff --git a/internal/registry/registry.go b/pkg/registry/registry.go similarity index 100% rename from internal/registry/registry.go rename to pkg/registry/registry.go diff --git a/internal/registry/registry_test.go b/pkg/registry/registry_test.go similarity index 100% rename from internal/registry/registry_test.go rename to pkg/registry/registry_test.go diff --git a/internal/registry/var.go b/pkg/registry/var.go similarity index 100% rename from internal/registry/var.go rename to pkg/registry/var.go diff --git a/pkg/template/template_data.go b/pkg/template/template_data.go index 2a3caeba..0a27a245 100644 --- a/pkg/template/template_data.go +++ b/pkg/template/template_data.go @@ -5,7 +5,7 @@ import ( "go/types" "strings" - "github.com/matryer/moq/internal/registry" + "github.com/vektra/mockery/v2/pkg/registry" ) // Data is the template data used to render the Moq template. diff --git a/pkg/template/template_test.go b/pkg/template/template_test.go index e977d48c..b675226e 100644 --- a/pkg/template/template_test.go +++ b/pkg/template/template_test.go @@ -4,7 +4,7 @@ import ( "go/types" "testing" - "github.com/matryer/moq/internal/registry" + "github.com/vektra/mockery/v2/pkg/registry" ) func TestTemplateFuncs(t *testing.T) { From e68ee26d0c27876129ed3a75180f074b17a1e7f2 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Thu, 19 Oct 2023 17:00:04 -0500 Subject: [PATCH 16/50] updates --- pkg/config/config.go | 2 + pkg/outputter.go | 85 ++++++++++++++++++++--------------- pkg/registry/registry_test.go | 6 +-- pkg/template/template.go | 42 ++++++++++++++--- pkg/template_generator.go | 29 ++++++++++++ 5 files changed, 119 insertions(+), 45 deletions(-) create mode 100644 pkg/template_generator.go diff --git a/pkg/config/config.go b/pkg/config/config.go index 2152d662..bd6fd345 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -63,6 +63,7 @@ type Config struct { Recursive bool `mapstructure:"recursive"` Exclude []string `mapstructure:"exclude"` SrcPkg string `mapstructure:"srcpkg"` + Style string `mapstructure:"style"` BoilerplateFile string `mapstructure:"boilerplate-file"` // StructName overrides the name given to the mock struct and should only be nonempty // when generating for an exact match (non regex expression in -name). @@ -96,6 +97,7 @@ func NewConfigFromViper(v *viper.Viper) (*Config, error) { v.SetDefault("case", "camel") v.SetDefault("dir", ".") v.SetDefault("output", "./mocks") + v.SetDefault("style", "mockery") } else { v.SetDefault("dir", "mocks/{{.PackagePath}}") v.SetDefault("filename", "mock_{{.InterfaceName}}.go") diff --git a/pkg/outputter.go b/pkg/outputter.go index 2f1a8192..9860513f 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -17,6 +17,7 @@ import ( "github.com/huandu/xstrings" "github.com/iancoleman/strcase" "github.com/rs/zerolog" + "github.com/rs/zerolog/log" "github.com/vektra/mockery/v2/pkg/config" "github.com/vektra/mockery/v2/pkg/logging" @@ -305,7 +306,7 @@ func NewOutputter( } } -func (m *Outputter) Generate(ctx context.Context, iface *Interface) error { +func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { log := zerolog.Ctx(ctx).With(). Str(logging.LogKeyInterface, iface.Name). Str(logging.LogKeyQualifiedName, iface.QualifiedName). @@ -315,7 +316,7 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error { log.Info().Msg("generating mocks for interface") log.Debug().Msg("getting config for interface") - interfaceConfigs, err := m.config.GetInterfaceConfig(ctx, iface.QualifiedName, iface.Name) + interfaceConfigs, err := o.config.GetInterfaceConfig(ctx, iface.QualifiedName, iface.Name) if err != nil { return err } @@ -323,48 +324,60 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error { for _, interfaceConfig := range interfaceConfigs { interfaceConfig.LogUnsupportedPackagesConfig(ctx) - log.Debug().Msg("getting mock generator") - if err := parseConfigTemplates(ctx, interfaceConfig, iface); err != nil { return fmt.Errorf("failed to parse config template: %w", err) } - - g := GeneratorConfig{ - Boilerplate: m.boilerplate, - DisableVersionString: interfaceConfig.DisableVersionString, - Exported: interfaceConfig.Exported, - InPackage: interfaceConfig.InPackage, - KeepTree: interfaceConfig.KeepTree, - Note: interfaceConfig.Note, - PackageName: interfaceConfig.Outpkg, - PackageNamePrefix: interfaceConfig.Packageprefix, - StructName: interfaceConfig.MockName, - UnrollVariadic: interfaceConfig.UnrollVariadic, - WithExpecter: interfaceConfig.WithExpecter, - ReplaceType: interfaceConfig.ReplaceType, + if interfaceConfig.Style == "mockery" { + o.generateMockery(ctx, iface, interfaceConfig) + continue } - generator := NewGenerator(ctx, g, iface, "") - log.Debug().Msg("generating mock in-memory") - if err := generator.GenerateAll(ctx); err != nil { - return err + config := TemplateGeneratorConfig{ + Style: interfaceConfig.Style, } + generator := NewTemplateGenerator(config) + fmt.Printf("generator: %v\n", generator) - outputPath := pathlib.NewPath(interfaceConfig.Dir).Join(interfaceConfig.FileName) - if err := outputPath.Parent().MkdirAll(); err != nil { - return stackerr.NewStackErrf(err, "failed to mkdir parents of: %v", outputPath) - } + } + return nil +} - fileLog := log.With().Stringer(logging.LogKeyFile, outputPath).Logger() - fileLog.Info().Msg("writing to file") - file, err := outputPath.OpenFile(os.O_RDWR | os.O_CREATE | os.O_TRUNC) - if err != nil { - return stackerr.NewStackErrf(err, "failed to open output file for mock: %v", outputPath) - } - defer file.Close() - if err := generator.Write(file); err != nil { - return stackerr.NewStackErrf(err, "failed to write to file") - } +func (o *Outputter) generateMockery(ctx context.Context, iface *Interface, interfaceConfig *config.Config) error { + g := GeneratorConfig{ + Boilerplate: o.boilerplate, + DisableVersionString: interfaceConfig.DisableVersionString, + Exported: interfaceConfig.Exported, + InPackage: interfaceConfig.InPackage, + KeepTree: interfaceConfig.KeepTree, + Note: interfaceConfig.Note, + PackageName: interfaceConfig.Outpkg, + PackageNamePrefix: interfaceConfig.Packageprefix, + StructName: interfaceConfig.MockName, + UnrollVariadic: interfaceConfig.UnrollVariadic, + WithExpecter: interfaceConfig.WithExpecter, + ReplaceType: interfaceConfig.ReplaceType, + } + generator := NewGenerator(ctx, g, iface, "") + + log.Debug().Msg("generating mock in-memory") + if err := generator.GenerateAll(ctx); err != nil { + return err + } + + outputPath := pathlib.NewPath(interfaceConfig.Dir).Join(interfaceConfig.FileName) + if err := outputPath.Parent().MkdirAll(); err != nil { + return stackerr.NewStackErrf(err, "failed to mkdir parents of: %v", outputPath) + } + + fileLog := log.With().Stringer(logging.LogKeyFile, outputPath).Logger() + fileLog.Info().Msg("writing to file") + file, err := outputPath.OpenFile(os.O_RDWR | os.O_CREATE | os.O_TRUNC) + if err != nil { + return stackerr.NewStackErrf(err, "failed to open output file for mock: %v", outputPath) + } + defer file.Close() + if err := generator.Write(file); err != nil { + return stackerr.NewStackErrf(err, "failed to write to file") } return nil } diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index 38011c6d..48f91328 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -1,13 +1,11 @@ -package registry_test +package registry import ( "testing" - - "github.com/matryer/moq/internal/registry" ) func BenchmarkNew(b *testing.B) { for i := 0; i < b.N; i++ { - registry.New("../../pkg/moq/testpackages/example", "") + New("../../pkg/moq/testpackages/example", "") } } diff --git a/pkg/template/template.go b/pkg/template/template.go index 1622101c..312ca4f3 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -2,7 +2,12 @@ package template import ( "io" + "strings" "text/template" + + _ "embed" + + "github.com/vektra/mockery/v2/pkg/registry" ) // Template is the Moq template. It is capable of generating the Moq @@ -12,15 +17,15 @@ type Template struct { } //go:embed moq.templ -var moqTemplate string +var templateMoq string -var styleMap = map[string]string{ - "moq": moqTemplate, +var styleTemplates = map[string]string{ + "moq": templateMoq, } // New returns a new instance of Template. func New(style string) (Template, error) { - tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(styleMap[style]) + tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(styleTemplates[style]) if err != nil { return Template{}, err } @@ -42,4 +47,31 @@ var golintInitialisms = []string{ "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", } -var templateFuncs = template.FuncMap{} +var templateFuncs = template.FuncMap{ + "ImportStatement": func(imprt *registry.Package) string { + if imprt.Alias == "" { + return `"` + imprt.Path() + `"` + } + return imprt.Alias + ` "` + imprt.Path() + `"` + }, + "SyncPkgQualifier": func(imports []*registry.Package) string { + for _, imprt := range imports { + if imprt.Path() == "sync" { + return imprt.Qualifier() + } + } + + return "sync" + }, + "Exported": func(s string) string { + if s == "" { + return "" + } + for _, initialism := range golintInitialisms { + if strings.ToUpper(s) == initialism { + return initialism + } + } + return strings.ToUpper(s[0:1]) + s[1:] + }, +} diff --git a/pkg/template_generator.go b/pkg/template_generator.go new file mode 100644 index 00000000..76d75fdf --- /dev/null +++ b/pkg/template_generator.go @@ -0,0 +1,29 @@ +package pkg + +import ( + "github.com/vektra/mockery/v2/pkg/registry" + "github.com/vektra/mockery/v2/pkg/template" +) + +type TemplateGeneratorConfig struct { + Style string +} +type TemplateGenerator struct { + config TemplateGeneratorConfig +} + +func NewTemplateGenerator(config TemplateGeneratorConfig) *TemplateGenerator { + return &TemplateGenerator{ + config: config, + } +} + +func (g *TemplateGenerator) Generate() error { + templ, err := template.New(g.config.Style) + if err != nil { + return err + } + data := registry. + + return nil +} From 3eb17fe513a5917525023b558f2ef761b415b436 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Thu, 19 Oct 2023 17:02:44 -0500 Subject: [PATCH 17/50] updates --- pkg/template/template.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/template/template.go b/pkg/template/template.go index 312ca4f3..e380afb3 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -8,6 +8,7 @@ import ( _ "embed" "github.com/vektra/mockery/v2/pkg/registry" + "github.com/vektra/mockery/v2/pkg/stackerr" ) // Template is the Moq template. It is capable of generating the Moq @@ -25,7 +26,12 @@ var styleTemplates = map[string]string{ // New returns a new instance of Template. func New(style string) (Template, error) { - tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(styleTemplates[style]) + templateString, styleExists := styleTemplates[style] + if !styleExists { + return Template{}, stackerr.NewStackErrf(nil, "style %s does not exist", style) + } + + tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(templateString) if err != nil { return Template{}, err } From 860c2c84140f8db8ff2a41bf015645062deafaa5 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Fri, 20 Oct 2023 12:54:21 -0500 Subject: [PATCH 18/50] updates --- cmd/mockery.go | 11 ++--- pkg/interface.go | 34 +++++++++++++++ pkg/method.go | 88 +++++++++++++++++++++++++++++++++++++++ pkg/outputter.go | 2 - pkg/parse.go | 31 -------------- pkg/registry/package.go | 24 +++++------ pkg/registry/registry.go | 32 +++----------- pkg/template_generator.go | 16 +++++-- 8 files changed, 156 insertions(+), 82 deletions(-) create mode 100644 pkg/interface.go create mode 100644 pkg/method.go diff --git a/cmd/mockery.go b/cmd/mockery.go index 922a16a8..64e98721 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -211,10 +211,6 @@ func (r *RootApp) Run() error { return nil } - var osp pkg.OutputStreamProvider - if r.Config.Print { - osp = &pkg.StdoutStreamProvider{} - } buildTags := strings.Split(r.Config.BuildTags, " ") var boilerplate string @@ -268,7 +264,7 @@ func (r *RootApp) Run() error { } ifaceLog.Debug().Msg("config specifies to generate this interface") - outputter := pkg.NewOutputter(&r.Config, boilerplate, true) + outputter := pkg.NewOutputter(&r.Config, boilerplate) if err := outputter.Generate(ifaceCtx, iface); err != nil { return err } @@ -277,6 +273,11 @@ func (r *RootApp) Run() error { return nil } + var osp pkg.OutputStreamProvider + if r.Config.Print { + osp = &pkg.StdoutStreamProvider{} + } + if r.Config.Name != "" && r.Config.All { log.Fatal().Msgf("Specify --name or --all, but not both") } else if (r.Config.FileName != "" || r.Config.StructName != "") && r.Config.All { diff --git a/pkg/interface.go b/pkg/interface.go new file mode 100644 index 00000000..64168107 --- /dev/null +++ b/pkg/interface.go @@ -0,0 +1,34 @@ +package pkg + +import ( + "go/ast" + "go/types" +) + +// Interface type represents the target type that we will generate a mock for. +// It could be an interface, or a function type. +// Function type emulates: an interface it has 1 method with the function signature +// and a general name, e.g. "Execute". +type Interface struct { + Name string // Name of the type to be mocked. + QualifiedName string // Path to the package of the target type. + FileName string + File *ast.File + Pkg TypesPackage + NamedType *types.Named + IsFunction bool // If true, this instance represents a function, otherwise it's an interface. + ActualInterface *types.Interface // Holds the actual interface type, in case it's an interface. + SingleFunction *Method // Holds the function type information, in case it's a function type. +} + +func (iface *Interface) Methods() []*Method { + if iface.IsFunction { + return []*Method{iface.SingleFunction} + } + methods := make([]*Method, iface.ActualInterface.NumMethods()) + for i := 0; i < iface.ActualInterface.NumMethods(); i++ { + fn := iface.ActualInterface.Method(i) + methods[i] = &Method{Name: fn.Name(), Signature: fn.Type().(*types.Signature)} + } + return methods +} diff --git a/pkg/method.go b/pkg/method.go new file mode 100644 index 00000000..07aedc8d --- /dev/null +++ b/pkg/method.go @@ -0,0 +1,88 @@ +package pkg + +import ( + "go/types" + "path" + "strings" +) + +type Method struct { + Name string + Signature *types.Signature +} + +type Imports map[string]*types.Package + +func (m Method) populateImports(imports Imports) { + for i := 0; i < m.Signature.Params().Len(); i++ { + m.importsHelper(m.Signature.Params().At(i).Type(), imports) + } +} + +// stripVendorPath strips the vendor dir prefix from a package path. +// For example we might encounter an absolute path like +// github.com/foo/bar/vendor/github.com/pkg/errors which is resolved +// to github.com/pkg/errors. +func stripVendorPath(p string) string { + parts := strings.Split(p, "/vendor/") + if len(parts) == 1 { + return p + } + return strings.TrimLeft(path.Join(parts[1:]...), "/") +} + +// importsHelper extracts all the package imports for a given type +// recursively. The imported packages by a single type can be more than +// one (ex: map[a.Type]b.Type). +func (m Method) importsHelper(elem types.Type, imports map[string]*types.Package) { + switch t := elem.(type) { + case *types.Named: + if pkg := t.Obj().Pkg(); pkg != nil { + imports[stripVendorPath(pkg.Path())] = pkg + } + // The imports of a Type with a TypeList must be added to the imports list + // For example: Foo[otherpackage.Bar] , must have otherpackage imported + if targs := t.TypeArgs(); targs != nil { + for i := 0; i < targs.Len(); i++ { + m.importsHelper(targs.At(i), imports) + } + } + + case *types.Array: + m.importsHelper(t.Elem(), imports) + + case *types.Slice: + m.importsHelper(t.Elem(), imports) + + case *types.Signature: + for i := 0; i < t.Params().Len(); i++ { + m.importsHelper(t.Params().At(i).Type(), imports) + } + for i := 0; i < t.Results().Len(); i++ { + m.importsHelper(t.Results().At(i).Type(), imports) + } + + case *types.Map: + m.importsHelper(t.Key(), imports) + m.importsHelper(t.Elem(), imports) + + case *types.Chan: + m.importsHelper(t.Elem(), imports) + + case *types.Pointer: + m.importsHelper(t.Elem(), imports) + + case *types.Struct: // anonymous struct + for i := 0; i < t.NumFields(); i++ { + m.importsHelper(t.Field(i).Type(), imports) + } + + case *types.Interface: // anonymous interface + for i := 0; i < t.NumExplicitMethods(); i++ { + m.importsHelper(t.ExplicitMethod(i).Type(), imports) + } + for i := 0; i < t.NumEmbeddeds(); i++ { + m.importsHelper(t.EmbeddedType(i), imports) + } + } +} diff --git a/pkg/outputter.go b/pkg/outputter.go index 9860513f..82cf76d1 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -297,12 +297,10 @@ type Outputter struct { func NewOutputter( config *config.Config, boilerplate string, - dryRun bool, ) *Outputter { return &Outputter{ boilerplate: boilerplate, config: config, - dryRun: dryRun, } } diff --git a/pkg/parse.go b/pkg/parse.go index e85077a9..c3836feb 100644 --- a/pkg/parse.go +++ b/pkg/parse.go @@ -261,43 +261,12 @@ func (p *Parser) packageInterfaces( return ifaces } -type Method struct { - Name string - Signature *types.Signature -} - type TypesPackage interface { Name() string Path() string } -// Interface type represents the target type that we will generate a mock for. -// It could be an interface, or a function type. -// Function type emulates: an interface it has 1 method with the function signature -// and a general name, e.g. "Execute". -type Interface struct { - Name string // Name of the type to be mocked. - QualifiedName string // Path to the package of the target type. - FileName string - File *ast.File - Pkg TypesPackage - NamedType *types.Named - IsFunction bool // If true, this instance represents a function, otherwise it's an interface. - ActualInterface *types.Interface // Holds the actual interface type, in case it's an interface. - SingleFunction *Method // Holds the function type information, in case it's a function type. -} -func (iface *Interface) Methods() []*Method { - if iface.IsFunction { - return []*Method{iface.SingleFunction} - } - methods := make([]*Method, iface.ActualInterface.NumMethods()) - for i := 0; i < iface.ActualInterface.NumMethods(); i++ { - fn := iface.ActualInterface.Method(i) - methods[i] = &Method{Name: fn.Name(), Signature: fn.Type().(*types.Signature)} - } - return methods -} type sortableIFaceList []*Interface diff --git a/pkg/registry/package.go b/pkg/registry/package.go index 37682424..d4945ea6 100644 --- a/pkg/registry/package.go +++ b/pkg/registry/package.go @@ -1,20 +1,26 @@ package registry import ( - "go/types" "path" "strings" ) +type TypesPackage interface { + Name() string + Path() string +} + // Package represents an imported package. type Package struct { - pkg *types.Package + pkg TypesPackage Alias string } // NewPackage creates a new instance of Package. -func NewPackage(pkg *types.Package) *Package { return &Package{pkg: pkg} } +func NewPackage(pkg TypesPackage) *Package { + return &Package{pkg: pkg} +} // Qualifier returns the qualifier which must be used to refer to types // declared in the package. @@ -66,17 +72,7 @@ func (p Package) uniqueName(lvl int) string { return name } -// stripVendorPath strips the vendor dir prefix from a package path. -// For example we might encounter an absolute path like -// github.com/foo/bar/vendor/github.com/pkg/errors which is resolved -// to github.com/pkg/errors. -func stripVendorPath(p string) string { - parts := strings.Split(p, "/vendor/") - if len(parts) == 1 { - return p - } - return strings.TrimLeft(path.Join(parts[1:]...), "/") -} + func min(a, b int) int { if a < b { diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index a237cdce..75a70c04 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -5,10 +5,10 @@ import ( "fmt" "go/ast" "go/types" - "path/filepath" "sort" "strings" + "github.com/chigopher/pathlib" "golang.org/x/tools/go/packages" ) @@ -19,25 +19,18 @@ import ( type Registry struct { srcPkgName string srcPkgTypes *types.Package - moqPkgPath string + outputPath *pathlib.Path aliases map[string]string imports map[string]*Package } // New loads the source package info and returns a new instance of // Registry. -func New(srcDir, moqPkg string) (*Registry, error) { - srcPkg, err := pkgInfoFromPath( - srcDir, packages.NeedName|packages.NeedSyntax|packages.NeedTypes, - ) - if err != nil { - return nil, fmt.Errorf("couldn't load source package: %s", err) - } - +func New(srcPkg *packages.Package, outputPath *pathlib.Path) (*Registry, error) { return &Registry{ srcPkgName: srcPkg.Name, srcPkgTypes: srcPkg.Types, - moqPkgPath: findPkgPath(moqPkg, srcPkg.PkgPath), + outputPath: outputPath, aliases: parseImportsAliases(srcPkg.Syntax), imports: make(map[string]*Package), }, nil @@ -78,7 +71,6 @@ func (r Registry) LookupInterface(name string) (*types.Interface, *types.TypePar func (r *Registry) MethodScope() *MethodScope { return &MethodScope{ registry: r, - moqPkgPath: r.moqPkgPath, conflicted: map[string]bool{}, } } @@ -88,7 +80,7 @@ func (r *Registry) MethodScope() *MethodScope { // packages. func (r *Registry) AddImport(pkg *types.Package) *Package { path := stripVendorPath(pkg.Path()) - if path == r.moqPkgPath { + if pathlib.NewPath(path).Equals(r.outputPath) { return nil } @@ -176,20 +168,6 @@ func pkgInfoFromPath(srcDir string, mode packages.LoadMode) (*packages.Package, return pkgs[0], nil } -func findPkgPath(pkgInputVal string, srcPkgPath string) string { - if pkgInputVal == "" { - return srcPkgPath - } - if pkgInDir(srcPkgPath, pkgInputVal) { - return srcPkgPath - } - subdirectoryPath := filepath.Join(srcPkgPath, pkgInputVal) - if pkgInDir(subdirectoryPath, pkgInputVal) { - return subdirectoryPath - } - return "" -} - func pkgInDir(pkgName, dir string) bool { currentPkg, err := pkgInfoFromPath(dir, packages.NeedName) if err != nil { diff --git a/pkg/template_generator.go b/pkg/template_generator.go index 76d75fdf..27da8568 100644 --- a/pkg/template_generator.go +++ b/pkg/template_generator.go @@ -1,7 +1,7 @@ package pkg import ( - "github.com/vektra/mockery/v2/pkg/registry" + "github.com/vektra/mockery/v2/pkg/config" "github.com/vektra/mockery/v2/pkg/template" ) @@ -18,12 +18,22 @@ func NewTemplateGenerator(config TemplateGeneratorConfig) *TemplateGenerator { } } -func (g *TemplateGenerator) Generate() error { +func (g *TemplateGenerator) Generate(iface *Interface, ifaceConfig *config.Config) error { templ, err := template.New(g.config.Style) if err != nil { return err } - data := registry. + imports := Imports{} + for _, method := range iface.Methods() { + method.populateImports(imports) + } + // TODO: Work on getting these imports into the template + + data := template.Data{ + PkgName: ifaceConfig.Outpkg, + SrcPkgQualifier: iface.Pkg.Name() + ".", + Imports: + } return nil } From d66be2c1d3e00173332b4190776743362c973cdb Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Sun, 19 Nov 2023 20:29:51 -0600 Subject: [PATCH 19/50] Add more code to plumb through all the values needed by moq registry methods In this commit, we gather all the template data needed by the moq logic to generate its template. This is untested as of yet. TODO: need to start testing this works by calling upon `moq` in `.mockery.yaml`. --- pkg/interface.go | 3 ++ pkg/outputter.go | 6 ++- pkg/parse.go | 22 ++++----- pkg/registry/method_scope.go | 2 +- pkg/registry/package.go | 5 +- pkg/registry/registry.go | 11 ++--- pkg/registry/registry_test.go | 10 ---- pkg/registry/var.go | 2 +- pkg/template_generator.go | 93 ++++++++++++++++++++++++++++++----- 9 files changed, 108 insertions(+), 46 deletions(-) diff --git a/pkg/interface.go b/pkg/interface.go index 64168107..d3b96986 100644 --- a/pkg/interface.go +++ b/pkg/interface.go @@ -3,6 +3,8 @@ package pkg import ( "go/ast" "go/types" + + "golang.org/x/tools/go/packages" ) // Interface type represents the target type that we will generate a mock for. @@ -14,6 +16,7 @@ type Interface struct { QualifiedName string // Path to the package of the target type. FileName string File *ast.File + PackagesPackage *packages.Package Pkg TypesPackage NamedType *types.Named IsFunction bool // If true, this instance represents a function, otherwise it's an interface. diff --git a/pkg/outputter.go b/pkg/outputter.go index 82cf76d1..4f8cd99b 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -333,7 +333,11 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { config := TemplateGeneratorConfig{ Style: interfaceConfig.Style, } - generator := NewTemplateGenerator(config) + generator, err := NewTemplateGenerator(iface.PackagesPackage, config) + if err != nil { + return fmt.Errorf("creating template generator: %w", err) + } + fmt.Printf("generator: %v\n", generator) } diff --git a/pkg/parse.go b/pkg/parse.go index c3836feb..e647c9ce 100644 --- a/pkg/parse.go +++ b/pkg/parse.go @@ -190,7 +190,7 @@ func (p *Parser) Find(name string) (*Interface, error) { for _, entry := range p.entries { for _, iface := range entry.interfaces { if iface == name { - list := p.packageInterfaces(entry.pkg.Types, entry.fileName, []string{name}, nil) + list := p.packageInterfaces(entry, []string{name}, nil) if len(list) > 0 { return list[0], nil } @@ -204,7 +204,7 @@ func (p *Parser) Interfaces() []*Interface { ifaces := make(sortableIFaceList, 0) for _, entry := range p.entries { declaredIfaces := entry.interfaces - ifaces = p.packageInterfaces(entry.pkg.Types, entry.fileName, declaredIfaces, ifaces) + ifaces = p.packageInterfaces(entry, declaredIfaces, ifaces) } sort.Sort(ifaces) @@ -212,11 +212,10 @@ func (p *Parser) Interfaces() []*Interface { } func (p *Parser) packageInterfaces( - pkg *types.Package, - fileName string, + entry *parserEntry, declaredInterfaces []string, ifaces []*Interface) []*Interface { - scope := pkg.Scope() + scope := entry.pkg.Types.Scope() for _, name := range declaredInterfaces { obj := scope.Lookup(name) if obj == nil { @@ -235,11 +234,12 @@ func (p *Parser) packageInterfaces( } elem := &Interface{ - Name: name, - Pkg: pkg, - QualifiedName: pkg.Path(), - FileName: fileName, - NamedType: typ, + Name: name, + PackagesPackage: entry.pkg, + Pkg: entry.pkg.Types, + QualifiedName: entry.pkg.Types.Path(), + FileName: entry.fileName, + NamedType: typ, } iface, ok := typ.Underlying().(*types.Interface) @@ -266,8 +266,6 @@ type TypesPackage interface { Path() string } - - type sortableIFaceList []*Interface func (s sortableIFaceList) Len() int { diff --git a/pkg/registry/method_scope.go b/pkg/registry/method_scope.go index 65b56162..8d301342 100644 --- a/pkg/registry/method_scope.go +++ b/pkg/registry/method_scope.go @@ -80,7 +80,7 @@ func (m MethodScope) populateImports(t types.Type, imports map[string]*Package) switch t := t.(type) { case *types.Named: if pkg := t.Obj().Pkg(); pkg != nil { - imports[stripVendorPath(pkg.Path())] = m.registry.AddImport(pkg) + imports[pkg.Path()] = m.registry.AddImport(pkg) } // The imports of a Type with a TypeList must be added to the imports list // For example: Foo[otherpackage.Bar] , must have otherpackage imported diff --git a/pkg/registry/package.go b/pkg/registry/package.go index d4945ea6..90192286 100644 --- a/pkg/registry/package.go +++ b/pkg/registry/package.go @@ -1,7 +1,6 @@ package registry import ( - "path" "strings" ) @@ -42,7 +41,7 @@ func (p *Package) Path() string { return "" } - return stripVendorPath(p.pkg.Path()) + return p.pkg.Path() } var replacer = strings.NewReplacer( @@ -72,8 +71,6 @@ func (p Package) uniqueName(lvl int) string { return name } - - func min(a, b int) int { if a < b { return a diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 75a70c04..3cc978a7 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -8,7 +8,6 @@ import ( "sort" "strings" - "github.com/chigopher/pathlib" "golang.org/x/tools/go/packages" ) @@ -18,19 +17,19 @@ import ( // qualifiers. type Registry struct { srcPkgName string + srcPkgPath string srcPkgTypes *types.Package - outputPath *pathlib.Path aliases map[string]string imports map[string]*Package } // New loads the source package info and returns a new instance of // Registry. -func New(srcPkg *packages.Package, outputPath *pathlib.Path) (*Registry, error) { +func New(srcPkg *packages.Package) (*Registry, error) { return &Registry{ srcPkgName: srcPkg.Name, + srcPkgPath: srcPkg.PkgPath, srcPkgTypes: srcPkg.Types, - outputPath: outputPath, aliases: parseImportsAliases(srcPkg.Syntax), imports: make(map[string]*Package), }, nil @@ -79,8 +78,8 @@ func (r *Registry) MethodScope() *MethodScope { // suitable alias if there are any conflicts with previously imported // packages. func (r *Registry) AddImport(pkg *types.Package) *Package { - path := stripVendorPath(pkg.Path()) - if pathlib.NewPath(path).Equals(r.outputPath) { + path := pkg.Path() + if pkg.Path() == r.srcPkgPath { return nil } diff --git a/pkg/registry/registry_test.go b/pkg/registry/registry_test.go index 48f91328..b2a276fb 100644 --- a/pkg/registry/registry_test.go +++ b/pkg/registry/registry_test.go @@ -1,11 +1 @@ package registry - -import ( - "testing" -) - -func BenchmarkNew(b *testing.B) { - for i := 0; i < b.N; i++ { - New("../../pkg/moq/testpackages/example", "") - } -} diff --git a/pkg/registry/var.go b/pkg/registry/var.go index 081a17c7..de8da2dc 100644 --- a/pkg/registry/var.go +++ b/pkg/registry/var.go @@ -30,7 +30,7 @@ func (v Var) TypeString() string { // packageQualifier is a types.Qualifier. func (v Var) packageQualifier(pkg *types.Package) string { - path := stripVendorPath(pkg.Path()) + path := pkg.Path() if v.moqPkgPath != "" && v.moqPkgPath == path { return "" } diff --git a/pkg/template_generator.go b/pkg/template_generator.go index 27da8568..b59c0f8b 100644 --- a/pkg/template_generator.go +++ b/pkg/template_generator.go @@ -1,39 +1,110 @@ package pkg import ( + "bytes" + "context" + "fmt" + "go/types" + + "github.com/chigopher/pathlib" + "github.com/rs/zerolog" "github.com/vektra/mockery/v2/pkg/config" + "github.com/vektra/mockery/v2/pkg/registry" "github.com/vektra/mockery/v2/pkg/template" + "golang.org/x/tools/go/packages" ) type TemplateGeneratorConfig struct { Style string } type TemplateGenerator struct { - config TemplateGeneratorConfig + config TemplateGeneratorConfig + registry *registry.Registry } -func NewTemplateGenerator(config TemplateGeneratorConfig) *TemplateGenerator { - return &TemplateGenerator{ - config: config, +func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConfig) (*TemplateGenerator, error) { + reg, err := registry.New(srcPkg) + if err != nil { + return nil, fmt.Errorf("creating new registry: %w", err) } + + return &TemplateGenerator{ + config: config, + registry: reg, + }, nil } -func (g *TemplateGenerator) Generate(iface *Interface, ifaceConfig *config.Config) error { - templ, err := template.New(g.config.Style) - if err != nil { - return err - } +func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifaceConfig *config.Config) error { + log := zerolog.Ctx(ctx) + log.Info().Msg("generating mock for interface") + imports := Imports{} for _, method := range iface.Methods() { method.populateImports(imports) } - // TODO: Work on getting these imports into the template + methods := make([]template.MethodData, iface.ActualInterface.NumMethods()) + + for i := 0; i < iface.ActualInterface.NumMethods(); i++ { + method := iface.ActualInterface.Method(i) + methodScope := g.registry.MethodScope() + + signature := method.Type().(*types.Signature) + params := make([]template.ParamData, signature.Params().Len()) + for j := 0; j < signature.Params().Len(); j++ { + param := signature.Params().At(j) + params[j] = template.ParamData{ + Var: methodScope.AddVar(param, ""), + Variadic: signature.Variadic() && j == signature.Params().Len()-1, + } + } + + returns := make([]template.ParamData, signature.Results().Len()) + for j := 0; j < signature.Results().Len(); j++ { + param := signature.Results().At(j) + returns[j] = template.ParamData{ + Var: methodScope.AddVar(param, "Out"), + Variadic: false, + } + } + methods[i] = template.MethodData{ + Name: method.Name(), + Params: params, + Returns: returns, + } + + } + + // For now, mockery only supports one mock per file, which is why we're creating + // a single-element list. moq seems to have supported multiple mocks per file. + mockData := []template.MockData{ + { + InterfaceName: iface.Name, + MockName: ifaceConfig.MockName, + Methods: methods, + }, + } data := template.Data{ PkgName: ifaceConfig.Outpkg, SrcPkgQualifier: iface.Pkg.Name() + ".", - Imports: + Imports: g.registry.Imports(), + Mocks: mockData, } + templ, err := template.New(g.config.Style) + if err != nil { + return fmt.Errorf("creating new template: %w", err) + } + + var buf bytes.Buffer + if err := templ.Execute(&buf, data); err != nil { + return fmt.Errorf("executing template: %w", err) + } + + outPath := pathlib.NewPath(ifaceConfig.Dir).Join(ifaceConfig.FileName) + if err := outPath.WriteFile(buf.Bytes()); err != nil { + log.Error().Err(err).Msg("couldn't write to output file") + return fmt.Errorf("writing to output file: %w", err) + } return nil } From 1edd82ffcf967f637d806e7523580aed979b4914 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Fri, 22 Dec 2023 21:27:53 -0600 Subject: [PATCH 20/50] Successfully created first moq --- .../v2/pkg/fixtures/RequesterReturnElided.go | 247 ++++++++---------- pkg/config/config.go | 4 + pkg/formatter.go | 31 +++ pkg/outputter.go | 8 +- pkg/registry/registry.go | 8 +- pkg/template_generator.go | 47 +++- 6 files changed, 192 insertions(+), 153 deletions(-) create mode 100644 pkg/formatter.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go index 7d7c7b30..b12a0c41 100644 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go @@ -1,158 +1,119 @@ -// Code generated by mockery. DO NOT EDIT. +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq package mocks -import mock "github.com/stretchr/testify/mock" - -// RequesterReturnElided is an autogenerated mock type for the RequesterReturnElided type +import ( + "github.com/vektra/mockery/v2/pkg/fixtures" + "sync" +) + +// Ensure, that RequesterReturnElided does implement test.RequesterReturnElided. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterReturnElided = &RequesterReturnElided{} + +// RequesterReturnElided is a mock implementation of test.RequesterReturnElided. +// +// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { +// +// // make and configure a mocked test.RequesterReturnElided +// mockedRequesterReturnElided := &RequesterReturnElided{ +// GetFunc: func(path string) (int, int, int, error) { +// panic("mock out the Get method") +// }, +// PutFunc: func(path string) (int, error) { +// panic("mock out the Put method") +// }, +// } +// +// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided +// // and then make assertions. +// +// } type RequesterReturnElided struct { - mock.Mock -} - -type RequesterReturnElided_Expecter struct { - mock *mock.Mock -} - -func (_m *RequesterReturnElided) EXPECT() *RequesterReturnElided_Expecter { - return &RequesterReturnElided_Expecter{mock: &_m.Mock} -} - -// Get provides a mock function with given fields: path -func (_m *RequesterReturnElided) Get(path string) (int, int, int, error) { - ret := _m.Called(path) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 int - var r1 int - var r2 int - var r3 error - if rf, ok := ret.Get(0).(func(string) (int, int, int, error)); ok { - return rf(path) - } - if rf, ok := ret.Get(0).(func(string) int); ok { - r0 = rf(path) - } else { - r0 = ret.Get(0).(int) + // GetFunc mocks the Get method. + GetFunc func(path string) (int, int, int, error) + + // PutFunc mocks the Put method. + PutFunc func(path string) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Put holds details about calls to the Put method. + Put []struct { + // Path is the path argument value. + Path string + } } + lockGet sync.RWMutex + lockPut sync.RWMutex +} - if rf, ok := ret.Get(1).(func(string) int); ok { - r1 = rf(path) - } else { - r1 = ret.Get(1).(int) +// Get calls GetFunc. +func (mock *RequesterReturnElided) Get(path string) (int, int, int, error) { + if mock.GetFunc == nil { + panic("RequesterReturnElided.GetFunc: method is nil but RequesterReturnElided.Get was just called") } - - if rf, ok := ret.Get(2).(func(string) int); ok { - r2 = rf(path) - } else { - r2 = ret.Get(2).(int) + callInfo := struct { + Path string + }{ + Path: path, } - - if rf, ok := ret.Get(3).(func(string) error); ok { - r3 = rf(path) - } else { - r3 = ret.Error(3) + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterReturnElided.GetCalls()) +func (mock *RequesterReturnElided) GetCalls() []struct { + Path string + } { + var calls []struct { + Path string } - - return r0, r1, r2, r3 -} - -// RequesterReturnElided_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type RequesterReturnElided_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - path string -func (_e *RequesterReturnElided_Expecter) Get(path interface{}) *RequesterReturnElided_Get_Call { - return &RequesterReturnElided_Get_Call{Call: _e.mock.On("Get", path)} -} - -func (_c *RequesterReturnElided_Get_Call) Run(run func(path string)) *RequesterReturnElided_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *RequesterReturnElided_Get_Call) Return(a int, b int, c int, err error) *RequesterReturnElided_Get_Call { - _c.Call.Return(a, b, c, err) - return _c -} - -func (_c *RequesterReturnElided_Get_Call) RunAndReturn(run func(string) (int, int, int, error)) *RequesterReturnElided_Get_Call { - _c.Call.Return(run) - return _c + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls } -// Put provides a mock function with given fields: path -func (_m *RequesterReturnElided) Put(path string) (int, error) { - ret := _m.Called(path) - - if len(ret) == 0 { - panic("no return value specified for Put") +// Put calls PutFunc. +func (mock *RequesterReturnElided) Put(path string) (int, error) { + if mock.PutFunc == nil { + panic("RequesterReturnElided.PutFunc: method is nil but RequesterReturnElided.Put was just called") } - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func(string) (int, error)); ok { - return rf(path) + callInfo := struct { + Path string + }{ + Path: path, } - if rf, ok := ret.Get(0).(func(string) int); ok { - r0 = rf(path) - } else { - r0 = ret.Get(0).(int) + mock.lockPut.Lock() + mock.calls.Put = append(mock.calls.Put, callInfo) + mock.lockPut.Unlock() + return mock.PutFunc(path) +} + +// PutCalls gets all the calls that were made to Put. +// Check the length with: +// +// len(mockedRequesterReturnElided.PutCalls()) +func (mock *RequesterReturnElided) PutCalls() []struct { + Path string + } { + var calls []struct { + Path string } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(path) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RequesterReturnElided_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' -type RequesterReturnElided_Put_Call struct { - *mock.Call -} - -// Put is a helper method to define mock.On call -// - path string -func (_e *RequesterReturnElided_Expecter) Put(path interface{}) *RequesterReturnElided_Put_Call { - return &RequesterReturnElided_Put_Call{Call: _e.mock.On("Put", path)} -} - -func (_c *RequesterReturnElided_Put_Call) Run(run func(path string)) *RequesterReturnElided_Put_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *RequesterReturnElided_Put_Call) Return(_a0 int, err error) *RequesterReturnElided_Put_Call { - _c.Call.Return(_a0, err) - return _c -} - -func (_c *RequesterReturnElided_Put_Call) RunAndReturn(run func(string) (int, error)) *RequesterReturnElided_Put_Call { - _c.Call.Return(run) - return _c -} - -// NewRequesterReturnElided creates a new instance of RequesterReturnElided. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewRequesterReturnElided(t interface { - mock.TestingT - Cleanup(func()) -}) *RequesterReturnElided { - mock := &RequesterReturnElided{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock + mock.lockPut.RLock() + calls = mock.calls.Put + mock.lockPut.RUnlock() + return calls } diff --git a/pkg/config/config.go b/pkg/config/config.go index bd6fd345..ab8f58e6 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -44,6 +44,7 @@ type Config struct { ExcludeRegex string `mapstructure:"exclude-regex"` Exported bool `mapstructure:"exported"` FileName string `mapstructure:"filename"` + Formatter string `mapstructure:"formatter"` IncludeAutoGenerated bool `mapstructure:"include-auto-generated"` IncludeRegex string `mapstructure:"include-regex"` InPackage bool `mapstructure:"inpackage"` @@ -62,6 +63,7 @@ type Config struct { Quiet bool `mapstructure:"quiet"` Recursive bool `mapstructure:"recursive"` Exclude []string `mapstructure:"exclude"` + SkipEnsure bool `mapstructure:"skip-ensure"` SrcPkg string `mapstructure:"srcpkg"` Style string `mapstructure:"style"` BoilerplateFile string `mapstructure:"boilerplate-file"` @@ -101,12 +103,14 @@ func NewConfigFromViper(v *viper.Viper) (*Config, error) { } else { v.SetDefault("dir", "mocks/{{.PackagePath}}") v.SetDefault("filename", "mock_{{.InterfaceName}}.go") + v.SetDefault("formatter", "goimports") v.SetDefault("include-auto-generated", true) v.SetDefault("mockname", "Mock{{.InterfaceName}}") v.SetDefault("outpkg", "{{.PackageName}}") v.SetDefault("with-expecter", true) v.SetDefault("dry-run", false) v.SetDefault("log-level", "info") + v.SetDefault("style", "mockery") } if err := v.UnmarshalExact(c); err != nil { diff --git a/pkg/formatter.go b/pkg/formatter.go new file mode 100644 index 00000000..236da80b --- /dev/null +++ b/pkg/formatter.go @@ -0,0 +1,31 @@ +package pkg + +import ( + "fmt" + "go/format" + + "golang.org/x/tools/imports" +) + +func goimports(src []byte) ([]byte, error) { + formatted, err := imports.Process("filename", src, &imports.Options{ + TabWidth: 8, + TabIndent: true, + Comments: true, + Fragment: true, + }) + if err != nil { + return nil, fmt.Errorf("goimports: %s", err) + } + + return formatted, nil +} + +func gofmt(src []byte) ([]byte, error) { + formatted, err := format.Source(src) + if err != nil { + return nil, fmt.Errorf("go/format: %s", err) + } + + return formatted, nil +} diff --git a/pkg/outputter.go b/pkg/outputter.go index 4f8cd99b..720137c8 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -321,24 +321,30 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { for _, interfaceConfig := range interfaceConfigs { interfaceConfig.LogUnsupportedPackagesConfig(ctx) + ifaceLog := log.With().Str("style", interfaceConfig.Style).Logger() if err := parseConfigTemplates(ctx, interfaceConfig, iface); err != nil { return fmt.Errorf("failed to parse config template: %w", err) } if interfaceConfig.Style == "mockery" { + ifaceLog.Debug().Msg("generating mockery mocks") o.generateMockery(ctx, iface, interfaceConfig) continue } + ifaceLog.Debug().Msg("generating templated mock") config := TemplateGeneratorConfig{ Style: interfaceConfig.Style, } - generator, err := NewTemplateGenerator(iface.PackagesPackage, config) + generator, err := NewTemplateGenerator(iface.PackagesPackage, config, interfaceConfig.Outpkg) if err != nil { return fmt.Errorf("creating template generator: %w", err) } fmt.Printf("generator: %v\n", generator) + if err := generator.Generate(ctx, iface, interfaceConfig); err != nil { + return fmt.Errorf("generating template: %w", err) + } } return nil diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 3cc978a7..b55c5635 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -16,8 +16,8 @@ import ( // imports and ensures there are no conflicts in the imported package // qualifiers. type Registry struct { + dstPkg string srcPkgName string - srcPkgPath string srcPkgTypes *types.Package aliases map[string]string imports map[string]*Package @@ -25,10 +25,10 @@ type Registry struct { // New loads the source package info and returns a new instance of // Registry. -func New(srcPkg *packages.Package) (*Registry, error) { +func New(srcPkg *packages.Package, dstPkg string) (*Registry, error) { return &Registry{ + dstPkg: dstPkg, srcPkgName: srcPkg.Name, - srcPkgPath: srcPkg.PkgPath, srcPkgTypes: srcPkg.Types, aliases: parseImportsAliases(srcPkg.Syntax), imports: make(map[string]*Package), @@ -79,7 +79,7 @@ func (r *Registry) MethodScope() *MethodScope { // packages. func (r *Registry) AddImport(pkg *types.Package) *Package { path := pkg.Path() - if pkg.Path() == r.srcPkgPath { + if path == r.dstPkg { return nil } diff --git a/pkg/template_generator.go b/pkg/template_generator.go index b59c0f8b..5b7c4fa6 100644 --- a/pkg/template_generator.go +++ b/pkg/template_generator.go @@ -22,8 +22,8 @@ type TemplateGenerator struct { registry *registry.Registry } -func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConfig) (*TemplateGenerator, error) { - reg, err := registry.New(srcPkg) +func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConfig, outPkg string) (*TemplateGenerator, error) { + reg, err := registry.New(srcPkg, outPkg) if err != nil { return nil, fmt.Errorf("creating new registry: %w", err) } @@ -34,9 +34,21 @@ func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConf }, nil } +func (g *TemplateGenerator) format(src []byte, ifaceConfig *config.Config) ([]byte, error) { + switch ifaceConfig.Formatter { + case "goimports": + return goimports(src) + + case "noop": + return src, nil + } + + return gofmt(src) +} + func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifaceConfig *config.Config) error { log := zerolog.Ctx(ctx) - log.Info().Msg("generating mock for interface") + log.Info().Msg("generating templated mock for interface") imports := Imports{} for _, method := range iface.Methods() { @@ -87,9 +99,25 @@ func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifac data := template.Data{ PkgName: ifaceConfig.Outpkg, SrcPkgQualifier: iface.Pkg.Name() + ".", - Imports: g.registry.Imports(), Mocks: mockData, + StubImpl: false, + SkipEnsure: false, + WithResets: false, } + if data.MocksSomeMethod() { + log.Debug().Msg("interface mocks some method, importing sync package") + g.registry.AddImport(types.NewPackage("sync", "sync")) + } + if g.registry.SrcPkgName() != ifaceConfig.Outpkg { + data.SrcPkgQualifier = g.registry.SrcPkgName() + "." + if !ifaceConfig.SkipEnsure { + log.Debug().Str("src-pkg", g.registry.SrcPkg().Path()).Msg("skip-ensure is false. Adding import for source package.") + imprt := g.registry.AddImport(g.registry.SrcPkg()) + log.Debug().Msgf("imprt: %v", imprt) + data.SrcPkgQualifier = imprt.Qualifier() + "." + } + } + data.Imports = g.registry.Imports() templ, err := template.New(g.config.Style) if err != nil { @@ -97,12 +125,21 @@ func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifac } var buf bytes.Buffer + log.Debug().Msg("executing template") if err := templ.Execute(&buf, data); err != nil { return fmt.Errorf("executing template: %w", err) } + //log.Debug().Msg("formatting file") + //formatted, err := g.format(buf.Bytes(), ifaceConfig) + //if err != nil { + // return fmt.Errorf("formatting mock file: %w", err) + //} + formatted := buf.Bytes() + outPath := pathlib.NewPath(ifaceConfig.Dir).Join(ifaceConfig.FileName) - if err := outPath.WriteFile(buf.Bytes()); err != nil { + log.Debug().Stringer("path", outPath).Msg("writing to path") + if err := outPath.WriteFile(formatted); err != nil { log.Error().Err(err).Msg("couldn't write to output file") return fmt.Errorf("writing to output file: %w", err) } From f19f1f129cb44146bdb3e1e6fd5743f94f9fc72e Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Fri, 22 Dec 2023 21:29:17 -0600 Subject: [PATCH 21/50] add config for moq --- .mockery.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.mockery.yaml b/.mockery.yaml index 25757954..991c2ea2 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -34,6 +34,11 @@ packages: with-expecter: True unroll-variadic: False RequesterReturnElided: + configs: + - mockname: RequesterReturnElided + style: mockery + - mockname: RequesterReturnElidedMoq + style: moq github.com/vektra/mockery/v2/pkg/fixtures/recursive_generation: config: recursive: True @@ -52,3 +57,4 @@ packages: filename: "mock_{{.InterfaceName}}_test.go" inpackage: True keeptree: False +# \ No newline at end of file From 852b19e9778f613638a79b701978791dfcff34c1 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Fri, 22 Dec 2023 21:31:51 -0600 Subject: [PATCH 22/50] add formatter back --- .../v2/pkg/fixtures/RequesterReturnElided.go | 247 ++++++++++-------- .../pkg/fixtures/RequesterReturnElidedMoq.go | 120 +++++++++ 2 files changed, 263 insertions(+), 104 deletions(-) create mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go index b12a0c41..7d7c7b30 100644 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go @@ -1,119 +1,158 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq +// Code generated by mockery. DO NOT EDIT. package mocks -import ( - "github.com/vektra/mockery/v2/pkg/fixtures" - "sync" -) - -// Ensure, that RequesterReturnElided does implement test.RequesterReturnElided. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterReturnElided = &RequesterReturnElided{} - -// RequesterReturnElided is a mock implementation of test.RequesterReturnElided. -// -// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { -// -// // make and configure a mocked test.RequesterReturnElided -// mockedRequesterReturnElided := &RequesterReturnElided{ -// GetFunc: func(path string) (int, int, int, error) { -// panic("mock out the Get method") -// }, -// PutFunc: func(path string) (int, error) { -// panic("mock out the Put method") -// }, -// } -// -// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided -// // and then make assertions. -// -// } +import mock "github.com/stretchr/testify/mock" + +// RequesterReturnElided is an autogenerated mock type for the RequesterReturnElided type type RequesterReturnElided struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (int, int, int, error) - - // PutFunc mocks the Put method. - PutFunc func(path string) (int, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - // Put holds details about calls to the Put method. - Put []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex - lockPut sync.RWMutex + mock.Mock +} + +type RequesterReturnElided_Expecter struct { + mock *mock.Mock +} + +func (_m *RequesterReturnElided) EXPECT() *RequesterReturnElided_Expecter { + return &RequesterReturnElided_Expecter{mock: &_m.Mock} } -// Get calls GetFunc. -func (mock *RequesterReturnElided) Get(path string) (int, int, int, error) { - if mock.GetFunc == nil { - panic("RequesterReturnElided.GetFunc: method is nil but RequesterReturnElided.Get was just called") +// Get provides a mock function with given fields: path +func (_m *RequesterReturnElided) Get(path string) (int, int, int, error) { + ret := _m.Called(path) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 int + var r1 int + var r2 int + var r3 error + if rf, ok := ret.Get(0).(func(string) (int, int, int, error)); ok { + return rf(path) + } + if rf, ok := ret.Get(0).(func(string) int); ok { + r0 = rf(path) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(string) int); ok { + r1 = rf(path) + } else { + r1 = ret.Get(1).(int) } - callInfo := struct { - Path string - }{ - Path: path, + + if rf, ok := ret.Get(2).(func(string) int); ok { + r2 = rf(path) + } else { + r2 = ret.Get(2).(int) } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterReturnElided.GetCalls()) -func (mock *RequesterReturnElided) GetCalls() []struct { - Path string - } { - var calls []struct { - Path string + + if rf, ok := ret.Get(3).(func(string) error); ok { + r3 = rf(path) + } else { + r3 = ret.Error(3) } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls + + return r0, r1, r2, r3 +} + +// RequesterReturnElided_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type RequesterReturnElided_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - path string +func (_e *RequesterReturnElided_Expecter) Get(path interface{}) *RequesterReturnElided_Get_Call { + return &RequesterReturnElided_Get_Call{Call: _e.mock.On("Get", path)} +} + +func (_c *RequesterReturnElided_Get_Call) Run(run func(path string)) *RequesterReturnElided_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *RequesterReturnElided_Get_Call) Return(a int, b int, c int, err error) *RequesterReturnElided_Get_Call { + _c.Call.Return(a, b, c, err) + return _c +} + +func (_c *RequesterReturnElided_Get_Call) RunAndReturn(run func(string) (int, int, int, error)) *RequesterReturnElided_Get_Call { + _c.Call.Return(run) + return _c } -// Put calls PutFunc. -func (mock *RequesterReturnElided) Put(path string) (int, error) { - if mock.PutFunc == nil { - panic("RequesterReturnElided.PutFunc: method is nil but RequesterReturnElided.Put was just called") +// Put provides a mock function with given fields: path +func (_m *RequesterReturnElided) Put(path string) (int, error) { + ret := _m.Called(path) + + if len(ret) == 0 { + panic("no return value specified for Put") } - callInfo := struct { - Path string - }{ - Path: path, + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(string) (int, error)); ok { + return rf(path) } - mock.lockPut.Lock() - mock.calls.Put = append(mock.calls.Put, callInfo) - mock.lockPut.Unlock() - return mock.PutFunc(path) -} - -// PutCalls gets all the calls that were made to Put. -// Check the length with: -// -// len(mockedRequesterReturnElided.PutCalls()) -func (mock *RequesterReturnElided) PutCalls() []struct { - Path string - } { - var calls []struct { - Path string + if rf, ok := ret.Get(0).(func(string) int); ok { + r0 = rf(path) + } else { + r0 = ret.Get(0).(int) } - mock.lockPut.RLock() - calls = mock.calls.Put - mock.lockPut.RUnlock() - return calls + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(path) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RequesterReturnElided_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' +type RequesterReturnElided_Put_Call struct { + *mock.Call +} + +// Put is a helper method to define mock.On call +// - path string +func (_e *RequesterReturnElided_Expecter) Put(path interface{}) *RequesterReturnElided_Put_Call { + return &RequesterReturnElided_Put_Call{Call: _e.mock.On("Put", path)} +} + +func (_c *RequesterReturnElided_Put_Call) Run(run func(path string)) *RequesterReturnElided_Put_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *RequesterReturnElided_Put_Call) Return(_a0 int, err error) *RequesterReturnElided_Put_Call { + _c.Call.Return(_a0, err) + return _c +} + +func (_c *RequesterReturnElided_Put_Call) RunAndReturn(run func(string) (int, error)) *RequesterReturnElided_Put_Call { + _c.Call.Return(run) + return _c +} + +// NewRequesterReturnElided creates a new instance of RequesterReturnElided. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRequesterReturnElided(t interface { + mock.TestingT + Cleanup(func()) +}) *RequesterReturnElided { + mock := &RequesterReturnElided{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock } diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go new file mode 100644 index 00000000..8455bbc7 --- /dev/null +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go @@ -0,0 +1,120 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package mocks + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterReturnElidedMoq does implement test.RequesterReturnElided. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterReturnElided = &RequesterReturnElidedMoq{} + +// RequesterReturnElidedMoq is a mock implementation of test.RequesterReturnElided. +// +// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { +// +// // make and configure a mocked test.RequesterReturnElided +// mockedRequesterReturnElided := &RequesterReturnElidedMoq{ +// GetFunc: func(path string) (int, int, int, error) { +// panic("mock out the Get method") +// }, +// PutFunc: func(path string) (int, error) { +// panic("mock out the Put method") +// }, +// } +// +// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided +// // and then make assertions. +// +// } +type RequesterReturnElidedMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (int, int, int, error) + + // PutFunc mocks the Put method. + PutFunc func(path string) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Put holds details about calls to the Put method. + Put []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex + lockPut sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterReturnElidedMoq) Get(path string) (int, int, int, error) { + if mock.GetFunc == nil { + panic("RequesterReturnElidedMoq.GetFunc: method is nil but RequesterReturnElided.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterReturnElided.GetCalls()) +func (mock *RequesterReturnElidedMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// Put calls PutFunc. +func (mock *RequesterReturnElidedMoq) Put(path string) (int, error) { + if mock.PutFunc == nil { + panic("RequesterReturnElidedMoq.PutFunc: method is nil but RequesterReturnElided.Put was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockPut.Lock() + mock.calls.Put = append(mock.calls.Put, callInfo) + mock.lockPut.Unlock() + return mock.PutFunc(path) +} + +// PutCalls gets all the calls that were made to Put. +// Check the length with: +// +// len(mockedRequesterReturnElided.PutCalls()) +func (mock *RequesterReturnElidedMoq) PutCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockPut.RLock() + calls = mock.calls.Put + mock.lockPut.RUnlock() + return calls +} From 9d89443926162150b4164c09d61bb846e5856570 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Fri, 22 Dec 2023 21:32:24 -0600 Subject: [PATCH 23/50] fix --- pkg/template_generator.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/template_generator.go b/pkg/template_generator.go index 5b7c4fa6..9769e3dc 100644 --- a/pkg/template_generator.go +++ b/pkg/template_generator.go @@ -130,12 +130,11 @@ func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifac return fmt.Errorf("executing template: %w", err) } - //log.Debug().Msg("formatting file") - //formatted, err := g.format(buf.Bytes(), ifaceConfig) - //if err != nil { - // return fmt.Errorf("formatting mock file: %w", err) - //} - formatted := buf.Bytes() + log.Debug().Msg("formatting file") + formatted, err := g.format(buf.Bytes(), ifaceConfig) + if err != nil { + return fmt.Errorf("formatting mock file: %w", err) + } outPath := pathlib.NewPath(ifaceConfig.Dir).Join(ifaceConfig.FileName) log.Debug().Stringer("path", outPath).Msg("writing to path") From 9aa5b53f10c3c8bd826759d708f18b991cee9c26 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 15:40:31 -0600 Subject: [PATCH 24/50] change moq.templ comment --- pkg/template/moq.templ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/template/moq.templ b/pkg/template/moq.templ index b3d3dc32..5770c443 100644 --- a/pkg/template/moq.templ +++ b/pkg/template/moq.templ @@ -1,5 +1,5 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery package {{.PkgName}} From e3fe47ce581745b1046e46703764f71144da8ed8 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 15:42:44 -0600 Subject: [PATCH 25/50] fix formatting issue with master merge --- pkg/outputter.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/outputter.go b/pkg/outputter.go index eb877179..f251c575 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -351,20 +351,20 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } func (o *Outputter) generateMockery(ctx context.Context, iface *Interface, interfaceConfig *config.Config) error { - g := GeneratorConfig{ - Boilerplate: m.boilerplate, - DisableVersionString: interfaceConfig.DisableVersionString, - Exported: interfaceConfig.Exported, - InPackage: interfaceConfig.InPackage, - KeepTree: interfaceConfig.KeepTree, - Note: interfaceConfig.Note, - MockBuildTags: interfaceConfig.MockBuildTags, - PackageName: interfaceConfig.Outpkg, - PackageNamePrefix: interfaceConfig.Packageprefix, - StructName: interfaceConfig.MockName, - UnrollVariadic: interfaceConfig.UnrollVariadic, - WithExpecter: interfaceConfig.WithExpecter, - ReplaceType: interfaceConfig.ReplaceType, + g := GeneratorConfig{ + Boilerplate: o.boilerplate, + DisableVersionString: interfaceConfig.DisableVersionString, + Exported: interfaceConfig.Exported, + InPackage: interfaceConfig.InPackage, + KeepTree: interfaceConfig.KeepTree, + Note: interfaceConfig.Note, + MockBuildTags: interfaceConfig.MockBuildTags, + PackageName: interfaceConfig.Outpkg, + PackageNamePrefix: interfaceConfig.Packageprefix, + StructName: interfaceConfig.MockName, + UnrollVariadic: interfaceConfig.UnrollVariadic, + WithExpecter: interfaceConfig.WithExpecter, + ReplaceType: interfaceConfig.ReplaceType, } generator := NewGenerator(ctx, g, iface, "") From 62ef48003e69cba34566ca87ed13ad2ba15c305a Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 17:08:07 -0600 Subject: [PATCH 26/50] Add generics plumbing through moq --- .mockery.yaml | 7 ++- pkg/method.go | 78 -------------------------- pkg/outputter.go | 5 +- pkg/template_generator.go | 113 +++++++++++++++++++++++++------------- 4 files changed, 85 insertions(+), 118 deletions(-) diff --git a/.mockery.yaml b/.mockery.yaml index 8c566849..59aec510 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -36,7 +36,12 @@ packages: unroll-variadic: False - mockname: Expecter unroll-variadic: True - RequesterReturnElided: + RequesterGenerics: + configs: + - mockname: RequesterGenerics + style: mockery + - mockname: RequesterGenericsMoq + style: moq VariadicNoReturnInterface: config: with-expecter: True diff --git a/pkg/method.go b/pkg/method.go index 07aedc8d..5f9c70ce 100644 --- a/pkg/method.go +++ b/pkg/method.go @@ -2,87 +2,9 @@ package pkg import ( "go/types" - "path" - "strings" ) type Method struct { Name string Signature *types.Signature } - -type Imports map[string]*types.Package - -func (m Method) populateImports(imports Imports) { - for i := 0; i < m.Signature.Params().Len(); i++ { - m.importsHelper(m.Signature.Params().At(i).Type(), imports) - } -} - -// stripVendorPath strips the vendor dir prefix from a package path. -// For example we might encounter an absolute path like -// github.com/foo/bar/vendor/github.com/pkg/errors which is resolved -// to github.com/pkg/errors. -func stripVendorPath(p string) string { - parts := strings.Split(p, "/vendor/") - if len(parts) == 1 { - return p - } - return strings.TrimLeft(path.Join(parts[1:]...), "/") -} - -// importsHelper extracts all the package imports for a given type -// recursively. The imported packages by a single type can be more than -// one (ex: map[a.Type]b.Type). -func (m Method) importsHelper(elem types.Type, imports map[string]*types.Package) { - switch t := elem.(type) { - case *types.Named: - if pkg := t.Obj().Pkg(); pkg != nil { - imports[stripVendorPath(pkg.Path())] = pkg - } - // The imports of a Type with a TypeList must be added to the imports list - // For example: Foo[otherpackage.Bar] , must have otherpackage imported - if targs := t.TypeArgs(); targs != nil { - for i := 0; i < targs.Len(); i++ { - m.importsHelper(targs.At(i), imports) - } - } - - case *types.Array: - m.importsHelper(t.Elem(), imports) - - case *types.Slice: - m.importsHelper(t.Elem(), imports) - - case *types.Signature: - for i := 0; i < t.Params().Len(); i++ { - m.importsHelper(t.Params().At(i).Type(), imports) - } - for i := 0; i < t.Results().Len(); i++ { - m.importsHelper(t.Results().At(i).Type(), imports) - } - - case *types.Map: - m.importsHelper(t.Key(), imports) - m.importsHelper(t.Elem(), imports) - - case *types.Chan: - m.importsHelper(t.Elem(), imports) - - case *types.Pointer: - m.importsHelper(t.Elem(), imports) - - case *types.Struct: // anonymous struct - for i := 0; i < t.NumFields(); i++ { - m.importsHelper(t.Field(i).Type(), imports) - } - - case *types.Interface: // anonymous interface - for i := 0; i < t.NumExplicitMethods(); i++ { - m.importsHelper(t.ExplicitMethod(i).Type(), imports) - } - for i := 0; i < t.NumEmbeddeds(); i++ { - m.importsHelper(t.EmbeddedType(i), imports) - } - } -} diff --git a/pkg/outputter.go b/pkg/outputter.go index f251c575..f30e5afc 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -17,7 +17,6 @@ import ( "github.com/huandu/xstrings" "github.com/iancoleman/strcase" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "github.com/vektra/mockery/v2/pkg/config" "github.com/vektra/mockery/v2/pkg/logging" @@ -342,7 +341,7 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } fmt.Printf("generator: %v\n", generator) - if err := generator.Generate(ctx, iface, interfaceConfig); err != nil { + if err := generator.Generate(ctx, iface.Name, interfaceConfig); err != nil { return fmt.Errorf("generating template: %w", err) } @@ -351,6 +350,8 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } func (o *Outputter) generateMockery(ctx context.Context, iface *Interface, interfaceConfig *config.Config) error { + log := zerolog.Ctx(ctx) + g := GeneratorConfig{ Boilerplate: o.boilerplate, DisableVersionString: interfaceConfig.DisableVersionString, diff --git a/pkg/template_generator.go b/pkg/template_generator.go index 9769e3dc..91729944 100644 --- a/pkg/template_generator.go +++ b/pkg/template_generator.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "go/token" "go/types" "github.com/chigopher/pathlib" @@ -46,63 +47,101 @@ func (g *TemplateGenerator) format(src []byte, ifaceConfig *config.Config) ([]by return gofmt(src) } -func (g *TemplateGenerator) Generate(ctx context.Context, iface *Interface, ifaceConfig *config.Config) error { - log := zerolog.Ctx(ctx) - log.Info().Msg("generating templated mock for interface") +func (g *TemplateGenerator) methodData(method *types.Func) template.MethodData { + methodScope := g.registry.MethodScope() - imports := Imports{} - for _, method := range iface.Methods() { - method.populateImports(imports) + signature := method.Type().(*types.Signature) + params := make([]template.ParamData, signature.Params().Len()) + for j := 0; j < signature.Params().Len(); j++ { + param := signature.Params().At(j) + params[j] = template.ParamData{ + Var: methodScope.AddVar(param, ""), + Variadic: signature.Variadic() && j == signature.Params().Len()-1, + } } - methods := make([]template.MethodData, iface.ActualInterface.NumMethods()) - for i := 0; i < iface.ActualInterface.NumMethods(); i++ { - method := iface.ActualInterface.Method(i) - methodScope := g.registry.MethodScope() - - signature := method.Type().(*types.Signature) - params := make([]template.ParamData, signature.Params().Len()) - for j := 0; j < signature.Params().Len(); j++ { - param := signature.Params().At(j) - params[j] = template.ParamData{ - Var: methodScope.AddVar(param, ""), - Variadic: signature.Variadic() && j == signature.Params().Len()-1, - } + returns := make([]template.ParamData, signature.Results().Len()) + for j := 0; j < signature.Results().Len(); j++ { + param := signature.Results().At(j) + returns[j] = template.ParamData{ + Var: methodScope.AddVar(param, "Out"), + Variadic: false, } + } + return template.MethodData{ + Name: method.Name(), + Params: params, + Returns: returns, + } +} - returns := make([]template.ParamData, signature.Results().Len()) - for j := 0; j < signature.Results().Len(); j++ { - param := signature.Results().At(j) - returns[j] = template.ParamData{ - Var: methodScope.AddVar(param, "Out"), - Variadic: false, - } +func explicitConstraintType(typeParam *types.Var) (t types.Type) { + underlying := typeParam.Type().Underlying().(*types.Interface) + // check if any of the embedded types is either a basic type or a union, + // because the generic type has to be an alias for one of those types then + for j := 0; j < underlying.NumEmbeddeds(); j++ { + t := underlying.EmbeddedType(j) + switch t := t.(type) { + case *types.Basic: + return t + case *types.Union: // only unions of basic types are allowed, so just take the first one as a valid type constraint + return t.Term(0).Type() } + } + return nil +} + +func (g *TemplateGenerator) typeParams(tparams *types.TypeParamList) []template.TypeParamData { + var tpd []template.TypeParamData + if tparams == nil { + return tpd + } + + tpd = make([]template.TypeParamData, tparams.Len()) - methods[i] = template.MethodData{ - Name: method.Name(), - Params: params, - Returns: returns, + scope := g.registry.MethodScope() + for i := 0; i < len(tpd); i++ { + tp := tparams.At(i) + typeParam := types.NewParam(token.Pos(i), tp.Obj().Pkg(), tp.Obj().Name(), tp.Constraint()) + tpd[i] = template.TypeParamData{ + ParamData: template.ParamData{Var: scope.AddVar(typeParam, "")}, + Constraint: explicitConstraintType(typeParam), } + } + + return tpd +} + +func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifaceConfig *config.Config) error { + log := zerolog.Ctx(ctx) + log.Info().Msg("generating templated mock for interface") + + iface, tparams, err := g.registry.LookupInterface(ifaceName) + if err != nil { + return err + } + methods := make([]template.MethodData, iface.NumMethods()) + for i := 0; i < iface.NumMethods(); i++ { + methods[i] = g.methodData(iface.Method(i)) } // For now, mockery only supports one mock per file, which is why we're creating // a single-element list. moq seems to have supported multiple mocks per file. mockData := []template.MockData{ { - InterfaceName: iface.Name, + InterfaceName: ifaceName, MockName: ifaceConfig.MockName, + TypeParams: g.typeParams(tparams), Methods: methods, }, } data := template.Data{ - PkgName: ifaceConfig.Outpkg, - SrcPkgQualifier: iface.Pkg.Name() + ".", - Mocks: mockData, - StubImpl: false, - SkipEnsure: false, - WithResets: false, + PkgName: ifaceConfig.Outpkg, + Mocks: mockData, + StubImpl: false, + SkipEnsure: false, + WithResets: false, } if data.MocksSomeMethod() { log.Debug().Msg("interface mocks some method, importing sync package") From 5d37c1819572310c043213065d3fae77f43ac6a4 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 17:08:34 -0600 Subject: [PATCH 27/50] update mocks with new features --- .../v2/pkg/fixtures/RequesterGenericsMoq.go | 179 ++++++++++++++++++ .../pkg/fixtures/RequesterReturnElidedMoq.go | 4 +- .../mockery/v2/pkg/fixtures/Variadic.go | 4 + .../v2/pkg/fixtures/VariadicReturnFunc.go | 4 + 4 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go new file mode 100644 index 00000000..2f07431d --- /dev/null +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go @@ -0,0 +1,179 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package mocks + +import ( + "io" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that RequesterGenericsMoq does implement test.RequesterGenerics. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int] = &RequesterGenericsMoq[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int]{} + +// RequesterGenericsMoq is a mock implementation of test.RequesterGenerics. +// +// func TestSomethingThatUsesRequesterGenerics(t *testing.T) { +// +// // make and configure a mocked test.RequesterGenerics +// mockedRequesterGenerics := &RequesterGenericsMoq{ +// GenericAnonymousStructsFunc: func(val struct{Type1 TExternalIntf}) struct{Type2 test.GenericType[string, test.EmbeddedGet[int]]} { +// panic("mock out the GenericAnonymousStructs method") +// }, +// GenericArgumentsFunc: func(v1 TAny, v2 TComparable) (TSigned, TIntf) { +// panic("mock out the GenericArguments method") +// }, +// GenericStructsFunc: func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { +// panic("mock out the GenericStructs method") +// }, +// } +// +// // use mockedRequesterGenerics in code that requires test.RequesterGenerics +// // and then make assertions. +// +// } +type RequesterGenericsMoq[TAny any, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { + ~int | GenericType[int, GetInt] + comparable +}] struct { + // GenericAnonymousStructsFunc mocks the GenericAnonymousStructs method. + GenericAnonymousStructsFunc func(val struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] + } + + // GenericArgumentsFunc mocks the GenericArguments method. + GenericArgumentsFunc func(v1 TAny, v2 TComparable) (TSigned, TIntf) + + // GenericStructsFunc mocks the GenericStructs method. + GenericStructsFunc func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] + + // calls tracks calls to the methods. + calls struct { + // GenericAnonymousStructs holds details about calls to the GenericAnonymousStructs method. + GenericAnonymousStructs []struct { + // Val is the val argument value. + Val struct{ Type1 TExternalIntf } + } + // GenericArguments holds details about calls to the GenericArguments method. + GenericArguments []struct { + // V1 is the v1 argument value. + V1 TAny + // V2 is the v2 argument value. + V2 TComparable + } + // GenericStructs holds details about calls to the GenericStructs method. + GenericStructs []struct { + // GenericType is the genericType argument value. + GenericType test.GenericType[TAny, TIntf] + } + } + lockGenericAnonymousStructs sync.RWMutex + lockGenericArguments sync.RWMutex + lockGenericStructs sync.RWMutex +} + +// GenericAnonymousStructs calls GenericAnonymousStructsFunc. +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructs(val struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] +} { + if mock.GenericAnonymousStructsFunc == nil { + panic("RequesterGenericsMoq.GenericAnonymousStructsFunc: method is nil but RequesterGenerics.GenericAnonymousStructs was just called") + } + callInfo := struct { + Val struct{ Type1 TExternalIntf } + }{ + Val: val, + } + mock.lockGenericAnonymousStructs.Lock() + mock.calls.GenericAnonymousStructs = append(mock.calls.GenericAnonymousStructs, callInfo) + mock.lockGenericAnonymousStructs.Unlock() + return mock.GenericAnonymousStructsFunc(val) +} + +// GenericAnonymousStructsCalls gets all the calls that were made to GenericAnonymousStructs. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericAnonymousStructsCalls()) +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructsCalls() []struct { + Val struct{ Type1 TExternalIntf } +} { + var calls []struct { + Val struct{ Type1 TExternalIntf } + } + mock.lockGenericAnonymousStructs.RLock() + calls = mock.calls.GenericAnonymousStructs + mock.lockGenericAnonymousStructs.RUnlock() + return calls +} + +// GenericArguments calls GenericArgumentsFunc. +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArguments(v1 TAny, v2 TComparable) (TSigned, TIntf) { + if mock.GenericArgumentsFunc == nil { + panic("RequesterGenericsMoq.GenericArgumentsFunc: method is nil but RequesterGenerics.GenericArguments was just called") + } + callInfo := struct { + V1 TAny + V2 TComparable + }{ + V1: v1, + V2: v2, + } + mock.lockGenericArguments.Lock() + mock.calls.GenericArguments = append(mock.calls.GenericArguments, callInfo) + mock.lockGenericArguments.Unlock() + return mock.GenericArgumentsFunc(v1, v2) +} + +// GenericArgumentsCalls gets all the calls that were made to GenericArguments. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericArgumentsCalls()) +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArgumentsCalls() []struct { + V1 TAny + V2 TComparable +} { + var calls []struct { + V1 TAny + V2 TComparable + } + mock.lockGenericArguments.RLock() + calls = mock.calls.GenericArguments + mock.lockGenericArguments.RUnlock() + return calls +} + +// GenericStructs calls GenericStructsFunc. +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructs(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { + if mock.GenericStructsFunc == nil { + panic("RequesterGenericsMoq.GenericStructsFunc: method is nil but RequesterGenerics.GenericStructs was just called") + } + callInfo := struct { + GenericType test.GenericType[TAny, TIntf] + }{ + GenericType: genericType, + } + mock.lockGenericStructs.Lock() + mock.calls.GenericStructs = append(mock.calls.GenericStructs, callInfo) + mock.lockGenericStructs.Unlock() + return mock.GenericStructsFunc(genericType) +} + +// GenericStructsCalls gets all the calls that were made to GenericStructs. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericStructsCalls()) +func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructsCalls() []struct { + GenericType test.GenericType[TAny, TIntf] +} { + var calls []struct { + GenericType test.GenericType[TAny, TIntf] + } + mock.lockGenericStructs.RLock() + calls = mock.calls.GenericStructs + mock.lockGenericStructs.RUnlock() + return calls +} diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go index 8455bbc7..7551d6a8 100644 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go @@ -1,5 +1,5 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery package mocks diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go index 4ee76f41..6b045d43 100644 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go @@ -21,6 +21,10 @@ func (_m *Variadic) EXPECT() *Variadic_Expecter { func (_m *Variadic) VariadicFunction(str string, vFunc func(string, ...interface{}) interface{}) error { ret := _m.Called(str, vFunc) + if len(ret) == 0 { + panic("no return value specified for VariadicFunction") + } + var r0 error if rf, ok := ret.Get(0).(func(string, func(string, ...interface{}) interface{}) error); ok { r0 = rf(str, vFunc) diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go index 181b07d9..b2c4918e 100644 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go @@ -21,6 +21,10 @@ func (_m *VariadicReturnFunc) EXPECT() *VariadicReturnFunc_Expecter { func (_m *VariadicReturnFunc) SampleMethod(str string) func(string, []int, ...interface{}) { ret := _m.Called(str) + if len(ret) == 0 { + panic("no return value specified for SampleMethod") + } + var r0 func(string, []int, ...interface{}) if rf, ok := ret.Get(0).(func(string) func(string, []int, ...interface{})); ok { r0 = rf(str) From f9bee2742cb08f39bdae00ffda413cdc8192367a Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:07:15 -0600 Subject: [PATCH 28/50] Move generator to separate package Disable generating mocks for functions in templated mocks --- .mockery.yaml | 6 - cmd/mockery.go | 2 +- .../v2/pkg/fixtures/RequesterGenericsMoq.go | 179 ------------------ .../mockery/v2/pkg/fixtures/SendFunc.go | 93 --------- pkg/formatter.go | 31 --- pkg/{ => generator}/template_generator.go | 31 ++- pkg/outputter.go | 6 +- pkg/parse.go | 20 +- 8 files changed, 52 insertions(+), 316 deletions(-) delete mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go delete mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go delete mode 100644 pkg/formatter.go rename pkg/{ => generator}/template_generator.go (89%) diff --git a/.mockery.yaml b/.mockery.yaml index 59aec510..0fdc361d 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -36,12 +36,6 @@ packages: unroll-variadic: False - mockname: Expecter unroll-variadic: True - RequesterGenerics: - configs: - - mockname: RequesterGenerics - style: mockery - - mockname: RequesterGenericsMoq - style: moq VariadicNoReturnInterface: config: with-expecter: True diff --git a/cmd/mockery.go b/cmd/mockery.go index 766d5193..d4fe203d 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -234,7 +234,7 @@ func (r *RootApp) Run() error { if err != nil { return fmt.Errorf("failed to get package from config: %w", err) } - parser := pkg.NewParser(buildTags) + parser := pkg.NewParser(buildTags, pkg.ParserSkipFunctions(true)) if err := parser.ParsePackages(ctx, configuredPackages); err != nil { log.Error().Err(err).Msg("unable to parse packages") diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go deleted file mode 100644 index 2f07431d..00000000 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenericsMoq.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package mocks - -import ( - "io" - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" - "github.com/vektra/mockery/v2/pkg/fixtures/constraints" -) - -// Ensure, that RequesterGenericsMoq does implement test.RequesterGenerics. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int] = &RequesterGenericsMoq[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int]{} - -// RequesterGenericsMoq is a mock implementation of test.RequesterGenerics. -// -// func TestSomethingThatUsesRequesterGenerics(t *testing.T) { -// -// // make and configure a mocked test.RequesterGenerics -// mockedRequesterGenerics := &RequesterGenericsMoq{ -// GenericAnonymousStructsFunc: func(val struct{Type1 TExternalIntf}) struct{Type2 test.GenericType[string, test.EmbeddedGet[int]]} { -// panic("mock out the GenericAnonymousStructs method") -// }, -// GenericArgumentsFunc: func(v1 TAny, v2 TComparable) (TSigned, TIntf) { -// panic("mock out the GenericArguments method") -// }, -// GenericStructsFunc: func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { -// panic("mock out the GenericStructs method") -// }, -// } -// -// // use mockedRequesterGenerics in code that requires test.RequesterGenerics -// // and then make assertions. -// -// } -type RequesterGenericsMoq[TAny any, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { - ~int | GenericType[int, GetInt] - comparable -}] struct { - // GenericAnonymousStructsFunc mocks the GenericAnonymousStructs method. - GenericAnonymousStructsFunc func(val struct{ Type1 TExternalIntf }) struct { - Type2 test.GenericType[string, test.EmbeddedGet[int]] - } - - // GenericArgumentsFunc mocks the GenericArguments method. - GenericArgumentsFunc func(v1 TAny, v2 TComparable) (TSigned, TIntf) - - // GenericStructsFunc mocks the GenericStructs method. - GenericStructsFunc func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] - - // calls tracks calls to the methods. - calls struct { - // GenericAnonymousStructs holds details about calls to the GenericAnonymousStructs method. - GenericAnonymousStructs []struct { - // Val is the val argument value. - Val struct{ Type1 TExternalIntf } - } - // GenericArguments holds details about calls to the GenericArguments method. - GenericArguments []struct { - // V1 is the v1 argument value. - V1 TAny - // V2 is the v2 argument value. - V2 TComparable - } - // GenericStructs holds details about calls to the GenericStructs method. - GenericStructs []struct { - // GenericType is the genericType argument value. - GenericType test.GenericType[TAny, TIntf] - } - } - lockGenericAnonymousStructs sync.RWMutex - lockGenericArguments sync.RWMutex - lockGenericStructs sync.RWMutex -} - -// GenericAnonymousStructs calls GenericAnonymousStructsFunc. -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructs(val struct{ Type1 TExternalIntf }) struct { - Type2 test.GenericType[string, test.EmbeddedGet[int]] -} { - if mock.GenericAnonymousStructsFunc == nil { - panic("RequesterGenericsMoq.GenericAnonymousStructsFunc: method is nil but RequesterGenerics.GenericAnonymousStructs was just called") - } - callInfo := struct { - Val struct{ Type1 TExternalIntf } - }{ - Val: val, - } - mock.lockGenericAnonymousStructs.Lock() - mock.calls.GenericAnonymousStructs = append(mock.calls.GenericAnonymousStructs, callInfo) - mock.lockGenericAnonymousStructs.Unlock() - return mock.GenericAnonymousStructsFunc(val) -} - -// GenericAnonymousStructsCalls gets all the calls that were made to GenericAnonymousStructs. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericAnonymousStructsCalls()) -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructsCalls() []struct { - Val struct{ Type1 TExternalIntf } -} { - var calls []struct { - Val struct{ Type1 TExternalIntf } - } - mock.lockGenericAnonymousStructs.RLock() - calls = mock.calls.GenericAnonymousStructs - mock.lockGenericAnonymousStructs.RUnlock() - return calls -} - -// GenericArguments calls GenericArgumentsFunc. -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArguments(v1 TAny, v2 TComparable) (TSigned, TIntf) { - if mock.GenericArgumentsFunc == nil { - panic("RequesterGenericsMoq.GenericArgumentsFunc: method is nil but RequesterGenerics.GenericArguments was just called") - } - callInfo := struct { - V1 TAny - V2 TComparable - }{ - V1: v1, - V2: v2, - } - mock.lockGenericArguments.Lock() - mock.calls.GenericArguments = append(mock.calls.GenericArguments, callInfo) - mock.lockGenericArguments.Unlock() - return mock.GenericArgumentsFunc(v1, v2) -} - -// GenericArgumentsCalls gets all the calls that were made to GenericArguments. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericArgumentsCalls()) -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArgumentsCalls() []struct { - V1 TAny - V2 TComparable -} { - var calls []struct { - V1 TAny - V2 TComparable - } - mock.lockGenericArguments.RLock() - calls = mock.calls.GenericArguments - mock.lockGenericArguments.RUnlock() - return calls -} - -// GenericStructs calls GenericStructsFunc. -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructs(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { - if mock.GenericStructsFunc == nil { - panic("RequesterGenericsMoq.GenericStructsFunc: method is nil but RequesterGenerics.GenericStructs was just called") - } - callInfo := struct { - GenericType test.GenericType[TAny, TIntf] - }{ - GenericType: genericType, - } - mock.lockGenericStructs.Lock() - mock.calls.GenericStructs = append(mock.calls.GenericStructs, callInfo) - mock.lockGenericStructs.Unlock() - return mock.GenericStructsFunc(genericType) -} - -// GenericStructsCalls gets all the calls that were made to GenericStructs. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericStructsCalls()) -func (mock *RequesterGenericsMoq[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructsCalls() []struct { - GenericType test.GenericType[TAny, TIntf] -} { - var calls []struct { - GenericType test.GenericType[TAny, TIntf] - } - mock.lockGenericStructs.RLock() - calls = mock.calls.GenericStructs - mock.lockGenericStructs.RUnlock() - return calls -} diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go deleted file mode 100644 index 740fe462..00000000 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package mocks - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// SendFunc is an autogenerated mock type for the SendFunc type -type SendFunc struct { - mock.Mock -} - -type SendFunc_Expecter struct { - mock *mock.Mock -} - -func (_m *SendFunc) EXPECT() *SendFunc_Expecter { - return &SendFunc_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: ctx, data -func (_m *SendFunc) Execute(ctx context.Context, data string) (int, error) { - ret := _m.Called(ctx, data) - - if len(ret) == 0 { - panic("no return value specified for Execute") - } - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (int, error)); ok { - return rf(ctx, data) - } - if rf, ok := ret.Get(0).(func(context.Context, string) int); ok { - r0 = rf(ctx, data) - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, data) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendFunc_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type SendFunc_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - ctx context.Context -// - data string -func (_e *SendFunc_Expecter) Execute(ctx interface{}, data interface{}) *SendFunc_Execute_Call { - return &SendFunc_Execute_Call{Call: _e.mock.On("Execute", ctx, data)} -} - -func (_c *SendFunc_Execute_Call) Run(run func(ctx context.Context, data string)) *SendFunc_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *SendFunc_Execute_Call) Return(_a0 int, _a1 error) *SendFunc_Execute_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *SendFunc_Execute_Call) RunAndReturn(run func(context.Context, string) (int, error)) *SendFunc_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewSendFunc creates a new instance of SendFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewSendFunc(t interface { - mock.TestingT - Cleanup(func()) -}) *SendFunc { - mock := &SendFunc{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/formatter.go b/pkg/formatter.go deleted file mode 100644 index 236da80b..00000000 --- a/pkg/formatter.go +++ /dev/null @@ -1,31 +0,0 @@ -package pkg - -import ( - "fmt" - "go/format" - - "golang.org/x/tools/imports" -) - -func goimports(src []byte) ([]byte, error) { - formatted, err := imports.Process("filename", src, &imports.Options{ - TabWidth: 8, - TabIndent: true, - Comments: true, - Fragment: true, - }) - if err != nil { - return nil, fmt.Errorf("goimports: %s", err) - } - - return formatted, nil -} - -func gofmt(src []byte) ([]byte, error) { - formatted, err := format.Source(src) - if err != nil { - return nil, fmt.Errorf("go/format: %s", err) - } - - return formatted, nil -} diff --git a/pkg/template_generator.go b/pkg/generator/template_generator.go similarity index 89% rename from pkg/template_generator.go rename to pkg/generator/template_generator.go index 91729944..1dce0b79 100644 --- a/pkg/template_generator.go +++ b/pkg/generator/template_generator.go @@ -1,9 +1,10 @@ -package pkg +package generator import ( "bytes" "context" "fmt" + "go/format" "go/token" "go/types" @@ -11,8 +12,10 @@ import ( "github.com/rs/zerolog" "github.com/vektra/mockery/v2/pkg/config" "github.com/vektra/mockery/v2/pkg/registry" + "github.com/vektra/mockery/v2/pkg/stackerr" "github.com/vektra/mockery/v2/pkg/template" "golang.org/x/tools/go/packages" + "golang.org/x/tools/imports" ) type TemplateGeneratorConfig struct { @@ -177,9 +180,35 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac outPath := pathlib.NewPath(ifaceConfig.Dir).Join(ifaceConfig.FileName) log.Debug().Stringer("path", outPath).Msg("writing to path") + if err := outPath.Parent().MkdirAll(); err != nil { + return stackerr.NewStackErr(err) + } if err := outPath.WriteFile(formatted); err != nil { log.Error().Err(err).Msg("couldn't write to output file") return fmt.Errorf("writing to output file: %w", err) } return nil } + +func goimports(src []byte) ([]byte, error) { + formatted, err := imports.Process("filename", src, &imports.Options{ + TabWidth: 8, + TabIndent: true, + Comments: true, + Fragment: true, + }) + if err != nil { + return nil, fmt.Errorf("goimports: %s", err) + } + + return formatted, nil +} + +func gofmt(src []byte) ([]byte, error) { + formatted, err := format.Source(src) + if err != nil { + return nil, fmt.Errorf("go/format: %s", err) + } + + return formatted, nil +} diff --git a/pkg/outputter.go b/pkg/outputter.go index f30e5afc..313e09a4 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -19,6 +19,7 @@ import ( "github.com/rs/zerolog" "github.com/vektra/mockery/v2/pkg/config" + "github.com/vektra/mockery/v2/pkg/generator" "github.com/vektra/mockery/v2/pkg/logging" "github.com/vektra/mockery/v2/pkg/stackerr" ) @@ -332,15 +333,14 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } ifaceLog.Debug().Msg("generating templated mock") - config := TemplateGeneratorConfig{ + config := generator.TemplateGeneratorConfig{ Style: interfaceConfig.Style, } - generator, err := NewTemplateGenerator(iface.PackagesPackage, config, interfaceConfig.Outpkg) + generator, err := generator.NewTemplateGenerator(iface.PackagesPackage, config, interfaceConfig.Outpkg) if err != nil { return fmt.Errorf("creating template generator: %w", err) } - fmt.Printf("generator: %v\n", generator) if err := generator.Generate(ctx, iface.Name, interfaceConfig); err != nil { return fmt.Errorf("generating template: %w", err) } diff --git a/pkg/parse.go b/pkg/parse.go index e647c9ce..49ebe0f6 100644 --- a/pkg/parse.go +++ b/pkg/parse.go @@ -34,9 +34,18 @@ type Parser struct { parserPackages []*types.Package conf packages.Config packageLoadCache map[string]packageLoadEntry + skipFunctions bool } -func NewParser(buildTags []string) *Parser { +type ParserOpts func(p *Parser) + +func ParserSkipFunctions(s bool) ParserOpts { + return func(p *Parser) { + p.skipFunctions = s + } +} + +func NewParser(buildTags []string, opts ...ParserOpts) *Parser { var conf packages.Config conf.Mode = packages.NeedTypes | packages.NeedTypesSizes | @@ -50,12 +59,17 @@ func NewParser(buildTags []string) *Parser { if len(buildTags) > 0 { conf.BuildFlags = []string{"-tags", strings.Join(buildTags, ",")} } - return &Parser{ + p := &Parser{ parserPackages: make([]*types.Package, 0), entriesByFileName: map[string]*parserEntry{}, conf: conf, packageLoadCache: map[string]packageLoadEntry{}, + skipFunctions: false, + } + for _, opt := range opts { + opt(p) } + return p } func (p *Parser) loadPackages(fpath string) ([]*packages.Package, error) { @@ -246,6 +260,8 @@ func (p *Parser) packageInterfaces( if ok { elem.IsFunction = false elem.ActualInterface = iface + } else if p.skipFunctions { + continue } else { sig, ok := typ.Underlying().(*types.Signature) if !ok { From 2ded46542965658a81d194ec407af50a7f0b55ce Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:44:17 -0600 Subject: [PATCH 29/50] Add moq configuration to Taskfile --- .mockery-moq.yaml | 13 +++++++++++++ Taskfile.yml | 2 ++ cmd/mockery.go | 1 + 3 files changed, 16 insertions(+) create mode 100644 .mockery-moq.yaml diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml new file mode 100644 index 00000000..cda21aec --- /dev/null +++ b/.mockery-moq.yaml @@ -0,0 +1,13 @@ +quiet: False +disable-version-string: True +with-expecter: True +mockname: "{{.InterfaceName}}" +filename: "{{.MockName}}.go" +dir: "mocks/moq/{{.PackagePath}}" +packages: + github.com/vektra/mockery/v2/pkg: + config: + all: True + recursive: True + style: moq + \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index 5e11bb39..1d8dfa19 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -23,11 +23,13 @@ tasks: cmds: - find . -name '*_mock.go' | xargs rm - rm -rf mocks/ + - rm -rf moqs/ mocks.generate: desc: generate mockery mocks cmds: - go run . + - go run . --config .mockery-moq.yaml docker: desc: build the mockery docker image diff --git a/cmd/mockery.go b/cmd/mockery.go index d4fe203d..ef72b105 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -83,6 +83,7 @@ func NewRootCmd() *cobra.Command { pFlags.Bool("exported", false, "Generates public mocks for private interfaces.") pFlags.Bool("with-expecter", false, "Generate expecter utility around mock's On, Run and Return methods with explicit types. This option is NOT compatible with -unroll-variadic=false") pFlags.StringArray("replace-type", nil, "Replace types") + pFlags.String("style", "", "select which mock style to use") if err := viperCfg.BindPFlags(pFlags); err != nil { panic(fmt.Sprintf("failed to bind PFlags: %v", err)) From f144fb585c1a113123bed581c5be577437cc2062 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:46:18 -0600 Subject: [PATCH 30/50] fix config --- .mockery-moq.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index cda21aec..97588b92 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -5,9 +5,9 @@ mockname: "{{.InterfaceName}}" filename: "{{.MockName}}.go" dir: "mocks/moq/{{.PackagePath}}" packages: - github.com/vektra/mockery/v2/pkg: + github.com/vektra/mockery/v2/pkg/fixtures: config: all: True - recursive: True style: moq + outpkg: testfoo \ No newline at end of file From 4a1905b5733857733059614290e7a10d954693ee Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:47:11 -0600 Subject: [PATCH 31/50] Add mocks for moq --- .../vektra/mockery/v2/pkg/fixtures/A.go | 69 +++++ .../mockery/v2/pkg/fixtures/AsyncProducer.go | 143 ++++++++++ .../vektra/mockery/v2/pkg/fixtures/Blank.go | 76 +++++ .../mockery/v2/pkg/fixtures/ConsulLock.go | 113 ++++++++ .../mockery/v2/pkg/fixtures/EmbeddedGet.go | 70 +++++ .../vektra/mockery/v2/pkg/fixtures/Example.go | 115 ++++++++ .../mockery/v2/pkg/fixtures/Expecter.go | 263 ++++++++++++++++++ .../vektra/mockery/v2/pkg/fixtures/Fooer.go | 164 +++++++++++ .../v2/pkg/fixtures/FuncArgsCollision.go | 76 +++++ .../mockery/v2/pkg/fixtures/GetGeneric.go | 70 +++++ .../vektra/mockery/v2/pkg/fixtures/GetInt.go | 69 +++++ .../fixtures/HasConflictingNestedImports.go | 115 ++++++++ .../v2/pkg/fixtures/ImportsSameAsPackage.go | 151 ++++++++++ .../mockery/v2/pkg/fixtures/KeyManager.go | 82 ++++++ .../vektra/mockery/v2/pkg/fixtures/MapFunc.go | 76 +++++ .../mockery/v2/pkg/fixtures/MapToInterface.go | 76 +++++ .../mockery/v2/pkg/fixtures/MyReader.go | 76 +++++ .../v2/pkg/fixtures/PanicOnNoReturnValue.go | 69 +++++ .../mockery/v2/pkg/fixtures/Requester.go | 76 +++++ .../mockery/v2/pkg/fixtures/Requester2.go | 76 +++++ .../mockery/v2/pkg/fixtures/Requester3.go | 69 +++++ .../mockery/v2/pkg/fixtures/Requester4.go | 69 +++++ .../pkg/fixtures/RequesterArgSameAsImport.go | 77 +++++ .../fixtures/RequesterArgSameAsNamedImport.go | 77 +++++ .../v2/pkg/fixtures/RequesterArgSameAsPkg.go | 76 +++++ .../mockery/v2/pkg/fixtures/RequesterArray.go | 76 +++++ .../v2/pkg/fixtures/RequesterElided.go | 82 ++++++ .../v2/pkg/fixtures/RequesterGenerics.go | 179 ++++++++++++ .../mockery/v2/pkg/fixtures/RequesterIface.go | 70 +++++ .../mockery/v2/pkg/fixtures/RequesterNS.go | 77 +++++ .../mockery/v2/pkg/fixtures/RequesterPtr.go | 76 +++++ .../v2/pkg/fixtures/RequesterReturnElided.go | 120 ++++++++ .../mockery/v2/pkg/fixtures/RequesterSlice.go | 76 +++++ .../v2/pkg/fixtures/RequesterVariadic.go | 221 +++++++++++++++ .../vektra/mockery/v2/pkg/fixtures/Sibling.go | 69 +++++ .../mockery/v2/pkg/fixtures/StructWithTag.go | 100 +++++++ .../v2/pkg/fixtures/UnsafeInterface.go | 76 +++++ .../v2/pkg/fixtures/UsesOtherPkgIface.go | 76 +++++ .../mockery/v2/pkg/fixtures/Variadic.go | 82 ++++++ .../pkg/fixtures/VariadicNoReturnInterface.go | 82 ++++++ .../v2/pkg/fixtures/VariadicReturnFunc.go | 76 +++++ .../v2/pkg/fixtures/requester_unexported.go | 67 +++++ 42 files changed, 3998 insertions(+) create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go new file mode 100644 index 00000000..99e21496 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that A does implement test.A. +// If this is not the case, regenerate this file with moq. +var _ test.A = &A{} + +// A is a mock implementation of test.A. +// +// func TestSomethingThatUsesA(t *testing.T) { +// +// // make and configure a mocked test.A +// mockedA := &A{ +// CallFunc: func() (test.B, error) { +// panic("mock out the Call method") +// }, +// } +// +// // use mockedA in code that requires test.A +// // and then make assertions. +// +// } +type A struct { + // CallFunc mocks the Call method. + CallFunc func() (test.B, error) + + // calls tracks calls to the methods. + calls struct { + // Call holds details about calls to the Call method. + Call []struct { + } + } + lockCall sync.RWMutex +} + +// Call calls CallFunc. +func (mock *A) Call() (test.B, error) { + if mock.CallFunc == nil { + panic("A.CallFunc: method is nil but A.Call was just called") + } + callInfo := struct { + }{} + mock.lockCall.Lock() + mock.calls.Call = append(mock.calls.Call, callInfo) + mock.lockCall.Unlock() + return mock.CallFunc() +} + +// CallCalls gets all the calls that were made to Call. +// Check the length with: +// +// len(mockedA.CallCalls()) +func (mock *A) CallCalls() []struct { +} { + var calls []struct { + } + mock.lockCall.RLock() + calls = mock.calls.Call + mock.lockCall.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go new file mode 100644 index 00000000..cc23dd22 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go @@ -0,0 +1,143 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that AsyncProducer does implement test.AsyncProducer. +// If this is not the case, regenerate this file with moq. +var _ test.AsyncProducer = &AsyncProducer{} + +// AsyncProducer is a mock implementation of test.AsyncProducer. +// +// func TestSomethingThatUsesAsyncProducer(t *testing.T) { +// +// // make and configure a mocked test.AsyncProducer +// mockedAsyncProducer := &AsyncProducer{ +// InputFunc: func() chan<- bool { +// panic("mock out the Input method") +// }, +// OutputFunc: func() <-chan bool { +// panic("mock out the Output method") +// }, +// WhateverFunc: func() chan bool { +// panic("mock out the Whatever method") +// }, +// } +// +// // use mockedAsyncProducer in code that requires test.AsyncProducer +// // and then make assertions. +// +// } +type AsyncProducer struct { + // InputFunc mocks the Input method. + InputFunc func() chan<- bool + + // OutputFunc mocks the Output method. + OutputFunc func() <-chan bool + + // WhateverFunc mocks the Whatever method. + WhateverFunc func() chan bool + + // calls tracks calls to the methods. + calls struct { + // Input holds details about calls to the Input method. + Input []struct { + } + // Output holds details about calls to the Output method. + Output []struct { + } + // Whatever holds details about calls to the Whatever method. + Whatever []struct { + } + } + lockInput sync.RWMutex + lockOutput sync.RWMutex + lockWhatever sync.RWMutex +} + +// Input calls InputFunc. +func (mock *AsyncProducer) Input() chan<- bool { + if mock.InputFunc == nil { + panic("AsyncProducer.InputFunc: method is nil but AsyncProducer.Input was just called") + } + callInfo := struct { + }{} + mock.lockInput.Lock() + mock.calls.Input = append(mock.calls.Input, callInfo) + mock.lockInput.Unlock() + return mock.InputFunc() +} + +// InputCalls gets all the calls that were made to Input. +// Check the length with: +// +// len(mockedAsyncProducer.InputCalls()) +func (mock *AsyncProducer) InputCalls() []struct { +} { + var calls []struct { + } + mock.lockInput.RLock() + calls = mock.calls.Input + mock.lockInput.RUnlock() + return calls +} + +// Output calls OutputFunc. +func (mock *AsyncProducer) Output() <-chan bool { + if mock.OutputFunc == nil { + panic("AsyncProducer.OutputFunc: method is nil but AsyncProducer.Output was just called") + } + callInfo := struct { + }{} + mock.lockOutput.Lock() + mock.calls.Output = append(mock.calls.Output, callInfo) + mock.lockOutput.Unlock() + return mock.OutputFunc() +} + +// OutputCalls gets all the calls that were made to Output. +// Check the length with: +// +// len(mockedAsyncProducer.OutputCalls()) +func (mock *AsyncProducer) OutputCalls() []struct { +} { + var calls []struct { + } + mock.lockOutput.RLock() + calls = mock.calls.Output + mock.lockOutput.RUnlock() + return calls +} + +// Whatever calls WhateverFunc. +func (mock *AsyncProducer) Whatever() chan bool { + if mock.WhateverFunc == nil { + panic("AsyncProducer.WhateverFunc: method is nil but AsyncProducer.Whatever was just called") + } + callInfo := struct { + }{} + mock.lockWhatever.Lock() + mock.calls.Whatever = append(mock.calls.Whatever, callInfo) + mock.lockWhatever.Unlock() + return mock.WhateverFunc() +} + +// WhateverCalls gets all the calls that were made to Whatever. +// Check the length with: +// +// len(mockedAsyncProducer.WhateverCalls()) +func (mock *AsyncProducer) WhateverCalls() []struct { +} { + var calls []struct { + } + mock.lockWhatever.RLock() + calls = mock.calls.Whatever + mock.lockWhatever.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go new file mode 100644 index 00000000..1bc7f8d6 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Blank does implement test.Blank. +// If this is not the case, regenerate this file with moq. +var _ test.Blank = &Blank{} + +// Blank is a mock implementation of test.Blank. +// +// func TestSomethingThatUsesBlank(t *testing.T) { +// +// // make and configure a mocked test.Blank +// mockedBlank := &Blank{ +// CreateFunc: func(x interface{}) error { +// panic("mock out the Create method") +// }, +// } +// +// // use mockedBlank in code that requires test.Blank +// // and then make assertions. +// +// } +type Blank struct { + // CreateFunc mocks the Create method. + CreateFunc func(x interface{}) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // X is the x argument value. + X interface{} + } + } + lockCreate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *Blank) Create(x interface{}) error { + if mock.CreateFunc == nil { + panic("Blank.CreateFunc: method is nil but Blank.Create was just called") + } + callInfo := struct { + X interface{} + }{ + X: x, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(x) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedBlank.CreateCalls()) +func (mock *Blank) CreateCalls() []struct { + X interface{} +} { + var calls []struct { + X interface{} + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go new file mode 100644 index 00000000..27b0c869 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go @@ -0,0 +1,113 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that ConsulLock does implement test.ConsulLock. +// If this is not the case, regenerate this file with moq. +var _ test.ConsulLock = &ConsulLock{} + +// ConsulLock is a mock implementation of test.ConsulLock. +// +// func TestSomethingThatUsesConsulLock(t *testing.T) { +// +// // make and configure a mocked test.ConsulLock +// mockedConsulLock := &ConsulLock{ +// LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { +// panic("mock out the Lock method") +// }, +// UnlockFunc: func() error { +// panic("mock out the Unlock method") +// }, +// } +// +// // use mockedConsulLock in code that requires test.ConsulLock +// // and then make assertions. +// +// } +type ConsulLock struct { + // LockFunc mocks the Lock method. + LockFunc func(valCh <-chan struct{}) (<-chan struct{}, error) + + // UnlockFunc mocks the Unlock method. + UnlockFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Lock holds details about calls to the Lock method. + Lock []struct { + // ValCh is the valCh argument value. + ValCh <-chan struct{} + } + // Unlock holds details about calls to the Unlock method. + Unlock []struct { + } + } + lockLock sync.RWMutex + lockUnlock sync.RWMutex +} + +// Lock calls LockFunc. +func (mock *ConsulLock) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { + if mock.LockFunc == nil { + panic("ConsulLock.LockFunc: method is nil but ConsulLock.Lock was just called") + } + callInfo := struct { + ValCh <-chan struct{} + }{ + ValCh: valCh, + } + mock.lockLock.Lock() + mock.calls.Lock = append(mock.calls.Lock, callInfo) + mock.lockLock.Unlock() + return mock.LockFunc(valCh) +} + +// LockCalls gets all the calls that were made to Lock. +// Check the length with: +// +// len(mockedConsulLock.LockCalls()) +func (mock *ConsulLock) LockCalls() []struct { + ValCh <-chan struct{} +} { + var calls []struct { + ValCh <-chan struct{} + } + mock.lockLock.RLock() + calls = mock.calls.Lock + mock.lockLock.RUnlock() + return calls +} + +// Unlock calls UnlockFunc. +func (mock *ConsulLock) Unlock() error { + if mock.UnlockFunc == nil { + panic("ConsulLock.UnlockFunc: method is nil but ConsulLock.Unlock was just called") + } + callInfo := struct { + }{} + mock.lockUnlock.Lock() + mock.calls.Unlock = append(mock.calls.Unlock, callInfo) + mock.lockUnlock.Unlock() + return mock.UnlockFunc() +} + +// UnlockCalls gets all the calls that were made to Unlock. +// Check the length with: +// +// len(mockedConsulLock.UnlockCalls()) +func (mock *ConsulLock) UnlockCalls() []struct { +} { + var calls []struct { + } + mock.lockUnlock.RLock() + calls = mock.calls.Unlock + mock.lockUnlock.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go new file mode 100644 index 00000000..7d199e3a --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go @@ -0,0 +1,70 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that EmbeddedGet does implement test.EmbeddedGet. +// If this is not the case, regenerate this file with moq. +var _ test.EmbeddedGet[int] = &EmbeddedGet[int]{} + +// EmbeddedGet is a mock implementation of test.EmbeddedGet. +// +// func TestSomethingThatUsesEmbeddedGet(t *testing.T) { +// +// // make and configure a mocked test.EmbeddedGet +// mockedEmbeddedGet := &EmbeddedGet{ +// GetFunc: func() T { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedEmbeddedGet in code that requires test.EmbeddedGet +// // and then make assertions. +// +// } +type EmbeddedGet[T constraints.Signed] struct { + // GetFunc mocks the Get method. + GetFunc func() T + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *EmbeddedGet[T]) Get() T { + if mock.GetFunc == nil { + panic("EmbeddedGet.GetFunc: method is nil but EmbeddedGet.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedEmbeddedGet.GetCalls()) +func (mock *EmbeddedGet[T]) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go new file mode 100644 index 00000000..96001a47 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go @@ -0,0 +1,115 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "net/http" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" +) + +// Ensure, that Example does implement test.Example. +// If this is not the case, regenerate this file with moq. +var _ test.Example = &Example{} + +// Example is a mock implementation of test.Example. +// +// func TestSomethingThatUsesExample(t *testing.T) { +// +// // make and configure a mocked test.Example +// mockedExample := &Example{ +// AFunc: func() http.Flusher { +// panic("mock out the A method") +// }, +// BFunc: func(fixtureshttp string) my_http.MyStruct { +// panic("mock out the B method") +// }, +// } +// +// // use mockedExample in code that requires test.Example +// // and then make assertions. +// +// } +type Example struct { + // AFunc mocks the A method. + AFunc func() http.Flusher + + // BFunc mocks the B method. + BFunc func(fixtureshttp string) my_http.MyStruct + + // calls tracks calls to the methods. + calls struct { + // A holds details about calls to the A method. + A []struct { + } + // B holds details about calls to the B method. + B []struct { + // Fixtureshttp is the fixtureshttp argument value. + Fixtureshttp string + } + } + lockA sync.RWMutex + lockB sync.RWMutex +} + +// A calls AFunc. +func (mock *Example) A() http.Flusher { + if mock.AFunc == nil { + panic("Example.AFunc: method is nil but Example.A was just called") + } + callInfo := struct { + }{} + mock.lockA.Lock() + mock.calls.A = append(mock.calls.A, callInfo) + mock.lockA.Unlock() + return mock.AFunc() +} + +// ACalls gets all the calls that were made to A. +// Check the length with: +// +// len(mockedExample.ACalls()) +func (mock *Example) ACalls() []struct { +} { + var calls []struct { + } + mock.lockA.RLock() + calls = mock.calls.A + mock.lockA.RUnlock() + return calls +} + +// B calls BFunc. +func (mock *Example) B(fixtureshttp string) my_http.MyStruct { + if mock.BFunc == nil { + panic("Example.BFunc: method is nil but Example.B was just called") + } + callInfo := struct { + Fixtureshttp string + }{ + Fixtureshttp: fixtureshttp, + } + mock.lockB.Lock() + mock.calls.B = append(mock.calls.B, callInfo) + mock.lockB.Unlock() + return mock.BFunc(fixtureshttp) +} + +// BCalls gets all the calls that were made to B. +// Check the length with: +// +// len(mockedExample.BCalls()) +func (mock *Example) BCalls() []struct { + Fixtureshttp string +} { + var calls []struct { + Fixtureshttp string + } + mock.lockB.RLock() + calls = mock.calls.B + mock.lockB.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go new file mode 100644 index 00000000..8b2abb10 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go @@ -0,0 +1,263 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Expecter does implement test.Expecter. +// If this is not the case, regenerate this file with moq. +var _ test.Expecter = &Expecter{} + +// Expecter is a mock implementation of test.Expecter. +// +// func TestSomethingThatUsesExpecter(t *testing.T) { +// +// // make and configure a mocked test.Expecter +// mockedExpecter := &Expecter{ +// ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { +// panic("mock out the ManyArgsReturns method") +// }, +// NoArgFunc: func() string { +// panic("mock out the NoArg method") +// }, +// NoReturnFunc: func(str string) { +// panic("mock out the NoReturn method") +// }, +// VariadicFunc: func(ints ...int) error { +// panic("mock out the Variadic method") +// }, +// VariadicManyFunc: func(i int, a string, intfs ...interface{}) error { +// panic("mock out the VariadicMany method") +// }, +// } +// +// // use mockedExpecter in code that requires test.Expecter +// // and then make assertions. +// +// } +type Expecter struct { + // ManyArgsReturnsFunc mocks the ManyArgsReturns method. + ManyArgsReturnsFunc func(str string, i int) ([]string, error) + + // NoArgFunc mocks the NoArg method. + NoArgFunc func() string + + // NoReturnFunc mocks the NoReturn method. + NoReturnFunc func(str string) + + // VariadicFunc mocks the Variadic method. + VariadicFunc func(ints ...int) error + + // VariadicManyFunc mocks the VariadicMany method. + VariadicManyFunc func(i int, a string, intfs ...interface{}) error + + // calls tracks calls to the methods. + calls struct { + // ManyArgsReturns holds details about calls to the ManyArgsReturns method. + ManyArgsReturns []struct { + // Str is the str argument value. + Str string + // I is the i argument value. + I int + } + // NoArg holds details about calls to the NoArg method. + NoArg []struct { + } + // NoReturn holds details about calls to the NoReturn method. + NoReturn []struct { + // Str is the str argument value. + Str string + } + // Variadic holds details about calls to the Variadic method. + Variadic []struct { + // Ints is the ints argument value. + Ints []int + } + // VariadicMany holds details about calls to the VariadicMany method. + VariadicMany []struct { + // I is the i argument value. + I int + // A is the a argument value. + A string + // Intfs is the intfs argument value. + Intfs []interface{} + } + } + lockManyArgsReturns sync.RWMutex + lockNoArg sync.RWMutex + lockNoReturn sync.RWMutex + lockVariadic sync.RWMutex + lockVariadicMany sync.RWMutex +} + +// ManyArgsReturns calls ManyArgsReturnsFunc. +func (mock *Expecter) ManyArgsReturns(str string, i int) ([]string, error) { + if mock.ManyArgsReturnsFunc == nil { + panic("Expecter.ManyArgsReturnsFunc: method is nil but Expecter.ManyArgsReturns was just called") + } + callInfo := struct { + Str string + I int + }{ + Str: str, + I: i, + } + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = append(mock.calls.ManyArgsReturns, callInfo) + mock.lockManyArgsReturns.Unlock() + return mock.ManyArgsReturnsFunc(str, i) +} + +// ManyArgsReturnsCalls gets all the calls that were made to ManyArgsReturns. +// Check the length with: +// +// len(mockedExpecter.ManyArgsReturnsCalls()) +func (mock *Expecter) ManyArgsReturnsCalls() []struct { + Str string + I int +} { + var calls []struct { + Str string + I int + } + mock.lockManyArgsReturns.RLock() + calls = mock.calls.ManyArgsReturns + mock.lockManyArgsReturns.RUnlock() + return calls +} + +// NoArg calls NoArgFunc. +func (mock *Expecter) NoArg() string { + if mock.NoArgFunc == nil { + panic("Expecter.NoArgFunc: method is nil but Expecter.NoArg was just called") + } + callInfo := struct { + }{} + mock.lockNoArg.Lock() + mock.calls.NoArg = append(mock.calls.NoArg, callInfo) + mock.lockNoArg.Unlock() + return mock.NoArgFunc() +} + +// NoArgCalls gets all the calls that were made to NoArg. +// Check the length with: +// +// len(mockedExpecter.NoArgCalls()) +func (mock *Expecter) NoArgCalls() []struct { +} { + var calls []struct { + } + mock.lockNoArg.RLock() + calls = mock.calls.NoArg + mock.lockNoArg.RUnlock() + return calls +} + +// NoReturn calls NoReturnFunc. +func (mock *Expecter) NoReturn(str string) { + if mock.NoReturnFunc == nil { + panic("Expecter.NoReturnFunc: method is nil but Expecter.NoReturn was just called") + } + callInfo := struct { + Str string + }{ + Str: str, + } + mock.lockNoReturn.Lock() + mock.calls.NoReturn = append(mock.calls.NoReturn, callInfo) + mock.lockNoReturn.Unlock() + mock.NoReturnFunc(str) +} + +// NoReturnCalls gets all the calls that were made to NoReturn. +// Check the length with: +// +// len(mockedExpecter.NoReturnCalls()) +func (mock *Expecter) NoReturnCalls() []struct { + Str string +} { + var calls []struct { + Str string + } + mock.lockNoReturn.RLock() + calls = mock.calls.NoReturn + mock.lockNoReturn.RUnlock() + return calls +} + +// Variadic calls VariadicFunc. +func (mock *Expecter) Variadic(ints ...int) error { + if mock.VariadicFunc == nil { + panic("Expecter.VariadicFunc: method is nil but Expecter.Variadic was just called") + } + callInfo := struct { + Ints []int + }{ + Ints: ints, + } + mock.lockVariadic.Lock() + mock.calls.Variadic = append(mock.calls.Variadic, callInfo) + mock.lockVariadic.Unlock() + return mock.VariadicFunc(ints...) +} + +// VariadicCalls gets all the calls that were made to Variadic. +// Check the length with: +// +// len(mockedExpecter.VariadicCalls()) +func (mock *Expecter) VariadicCalls() []struct { + Ints []int +} { + var calls []struct { + Ints []int + } + mock.lockVariadic.RLock() + calls = mock.calls.Variadic + mock.lockVariadic.RUnlock() + return calls +} + +// VariadicMany calls VariadicManyFunc. +func (mock *Expecter) VariadicMany(i int, a string, intfs ...interface{}) error { + if mock.VariadicManyFunc == nil { + panic("Expecter.VariadicManyFunc: method is nil but Expecter.VariadicMany was just called") + } + callInfo := struct { + I int + A string + Intfs []interface{} + }{ + I: i, + A: a, + Intfs: intfs, + } + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = append(mock.calls.VariadicMany, callInfo) + mock.lockVariadicMany.Unlock() + return mock.VariadicManyFunc(i, a, intfs...) +} + +// VariadicManyCalls gets all the calls that were made to VariadicMany. +// Check the length with: +// +// len(mockedExpecter.VariadicManyCalls()) +func (mock *Expecter) VariadicManyCalls() []struct { + I int + A string + Intfs []interface{} +} { + var calls []struct { + I int + A string + Intfs []interface{} + } + mock.lockVariadicMany.RLock() + calls = mock.calls.VariadicMany + mock.lockVariadicMany.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go new file mode 100644 index 00000000..09eb6803 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go @@ -0,0 +1,164 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Fooer does implement test.Fooer. +// If this is not the case, regenerate this file with moq. +var _ test.Fooer = &Fooer{} + +// Fooer is a mock implementation of test.Fooer. +// +// func TestSomethingThatUsesFooer(t *testing.T) { +// +// // make and configure a mocked test.Fooer +// mockedFooer := &Fooer{ +// BarFunc: func(f func([]int)) { +// panic("mock out the Bar method") +// }, +// BazFunc: func(path string) func(x string) string { +// panic("mock out the Baz method") +// }, +// FooFunc: func(f func(x string) string) error { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedFooer in code that requires test.Fooer +// // and then make assertions. +// +// } +type Fooer struct { + // BarFunc mocks the Bar method. + BarFunc func(f func([]int)) + + // BazFunc mocks the Baz method. + BazFunc func(path string) func(x string) string + + // FooFunc mocks the Foo method. + FooFunc func(f func(x string) string) error + + // calls tracks calls to the methods. + calls struct { + // Bar holds details about calls to the Bar method. + Bar []struct { + // F is the f argument value. + F func([]int) + } + // Baz holds details about calls to the Baz method. + Baz []struct { + // Path is the path argument value. + Path string + } + // Foo holds details about calls to the Foo method. + Foo []struct { + // F is the f argument value. + F func(x string) string + } + } + lockBar sync.RWMutex + lockBaz sync.RWMutex + lockFoo sync.RWMutex +} + +// Bar calls BarFunc. +func (mock *Fooer) Bar(f func([]int)) { + if mock.BarFunc == nil { + panic("Fooer.BarFunc: method is nil but Fooer.Bar was just called") + } + callInfo := struct { + F func([]int) + }{ + F: f, + } + mock.lockBar.Lock() + mock.calls.Bar = append(mock.calls.Bar, callInfo) + mock.lockBar.Unlock() + mock.BarFunc(f) +} + +// BarCalls gets all the calls that were made to Bar. +// Check the length with: +// +// len(mockedFooer.BarCalls()) +func (mock *Fooer) BarCalls() []struct { + F func([]int) +} { + var calls []struct { + F func([]int) + } + mock.lockBar.RLock() + calls = mock.calls.Bar + mock.lockBar.RUnlock() + return calls +} + +// Baz calls BazFunc. +func (mock *Fooer) Baz(path string) func(x string) string { + if mock.BazFunc == nil { + panic("Fooer.BazFunc: method is nil but Fooer.Baz was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockBaz.Lock() + mock.calls.Baz = append(mock.calls.Baz, callInfo) + mock.lockBaz.Unlock() + return mock.BazFunc(path) +} + +// BazCalls gets all the calls that were made to Baz. +// Check the length with: +// +// len(mockedFooer.BazCalls()) +func (mock *Fooer) BazCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockBaz.RLock() + calls = mock.calls.Baz + mock.lockBaz.RUnlock() + return calls +} + +// Foo calls FooFunc. +func (mock *Fooer) Foo(f func(x string) string) error { + if mock.FooFunc == nil { + panic("Fooer.FooFunc: method is nil but Fooer.Foo was just called") + } + callInfo := struct { + F func(x string) string + }{ + F: f, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + return mock.FooFunc(f) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedFooer.FooCalls()) +func (mock *Fooer) FooCalls() []struct { + F func(x string) string +} { + var calls []struct { + F func(x string) string + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go new file mode 100644 index 00000000..7aa0374e --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that FuncArgsCollision does implement test.FuncArgsCollision. +// If this is not the case, regenerate this file with moq. +var _ test.FuncArgsCollision = &FuncArgsCollision{} + +// FuncArgsCollision is a mock implementation of test.FuncArgsCollision. +// +// func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { +// +// // make and configure a mocked test.FuncArgsCollision +// mockedFuncArgsCollision := &FuncArgsCollision{ +// FooFunc: func(ret interface{}) error { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedFuncArgsCollision in code that requires test.FuncArgsCollision +// // and then make assertions. +// +// } +type FuncArgsCollision struct { + // FooFunc mocks the Foo method. + FooFunc func(ret interface{}) error + + // calls tracks calls to the methods. + calls struct { + // Foo holds details about calls to the Foo method. + Foo []struct { + // Ret is the ret argument value. + Ret interface{} + } + } + lockFoo sync.RWMutex +} + +// Foo calls FooFunc. +func (mock *FuncArgsCollision) Foo(ret interface{}) error { + if mock.FooFunc == nil { + panic("FuncArgsCollision.FooFunc: method is nil but FuncArgsCollision.Foo was just called") + } + callInfo := struct { + Ret interface{} + }{ + Ret: ret, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + return mock.FooFunc(ret) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedFuncArgsCollision.FooCalls()) +func (mock *FuncArgsCollision) FooCalls() []struct { + Ret interface{} +} { + var calls []struct { + Ret interface{} + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go new file mode 100644 index 00000000..9ebffbdc --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go @@ -0,0 +1,70 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that GetGeneric does implement test.GetGeneric. +// If this is not the case, regenerate this file with moq. +var _ test.GetGeneric[int] = &GetGeneric[int]{} + +// GetGeneric is a mock implementation of test.GetGeneric. +// +// func TestSomethingThatUsesGetGeneric(t *testing.T) { +// +// // make and configure a mocked test.GetGeneric +// mockedGetGeneric := &GetGeneric{ +// GetFunc: func() T { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedGetGeneric in code that requires test.GetGeneric +// // and then make assertions. +// +// } +type GetGeneric[T constraints.Integer] struct { + // GetFunc mocks the Get method. + GetFunc func() T + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *GetGeneric[T]) Get() T { + if mock.GetFunc == nil { + panic("GetGeneric.GetFunc: method is nil but GetGeneric.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedGetGeneric.GetCalls()) +func (mock *GetGeneric[T]) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go new file mode 100644 index 00000000..5bc165d4 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that GetInt does implement test.GetInt. +// If this is not the case, regenerate this file with moq. +var _ test.GetInt = &GetInt{} + +// GetInt is a mock implementation of test.GetInt. +// +// func TestSomethingThatUsesGetInt(t *testing.T) { +// +// // make and configure a mocked test.GetInt +// mockedGetInt := &GetInt{ +// GetFunc: func() int { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedGetInt in code that requires test.GetInt +// // and then make assertions. +// +// } +type GetInt struct { + // GetFunc mocks the Get method. + GetFunc func() int + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *GetInt) Get() int { + if mock.GetFunc == nil { + panic("GetInt.GetFunc: method is nil but GetInt.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedGetInt.GetCalls()) +func (mock *GetInt) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go new file mode 100644 index 00000000..eb30a280 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go @@ -0,0 +1,115 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "net/http" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" +) + +// Ensure, that HasConflictingNestedImports does implement test.HasConflictingNestedImports. +// If this is not the case, regenerate this file with moq. +var _ test.HasConflictingNestedImports = &HasConflictingNestedImports{} + +// HasConflictingNestedImports is a mock implementation of test.HasConflictingNestedImports. +// +// func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { +// +// // make and configure a mocked test.HasConflictingNestedImports +// mockedHasConflictingNestedImports := &HasConflictingNestedImports{ +// GetFunc: func(path string) (http.Response, error) { +// panic("mock out the Get method") +// }, +// ZFunc: func() my_http.MyStruct { +// panic("mock out the Z method") +// }, +// } +// +// // use mockedHasConflictingNestedImports in code that requires test.HasConflictingNestedImports +// // and then make assertions. +// +// } +type HasConflictingNestedImports struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (http.Response, error) + + // ZFunc mocks the Z method. + ZFunc func() my_http.MyStruct + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Z holds details about calls to the Z method. + Z []struct { + } + } + lockGet sync.RWMutex + lockZ sync.RWMutex +} + +// Get calls GetFunc. +func (mock *HasConflictingNestedImports) Get(path string) (http.Response, error) { + if mock.GetFunc == nil { + panic("HasConflictingNestedImports.GetFunc: method is nil but HasConflictingNestedImports.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedHasConflictingNestedImports.GetCalls()) +func (mock *HasConflictingNestedImports) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// Z calls ZFunc. +func (mock *HasConflictingNestedImports) Z() my_http.MyStruct { + if mock.ZFunc == nil { + panic("HasConflictingNestedImports.ZFunc: method is nil but HasConflictingNestedImports.Z was just called") + } + callInfo := struct { + }{} + mock.lockZ.Lock() + mock.calls.Z = append(mock.calls.Z, callInfo) + mock.lockZ.Unlock() + return mock.ZFunc() +} + +// ZCalls gets all the calls that were made to Z. +// Check the length with: +// +// len(mockedHasConflictingNestedImports.ZCalls()) +func (mock *HasConflictingNestedImports) ZCalls() []struct { +} { + var calls []struct { + } + mock.lockZ.RLock() + calls = mock.calls.Z + mock.lockZ.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go new file mode 100644 index 00000000..423e2bf3 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go @@ -0,0 +1,151 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + fixtures "github.com/vektra/mockery/v2/pkg/fixtures" + redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" +) + +// Ensure, that ImportsSameAsPackage does implement fixtures.ImportsSameAsPackage. +// If this is not the case, regenerate this file with moq. +var _ fixtures.ImportsSameAsPackage = &ImportsSameAsPackage{} + +// ImportsSameAsPackage is a mock implementation of fixtures.ImportsSameAsPackage. +// +// func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { +// +// // make and configure a mocked fixtures.ImportsSameAsPackage +// mockedImportsSameAsPackage := &ImportsSameAsPackage{ +// AFunc: func() redefinedtypeb.B { +// panic("mock out the A method") +// }, +// BFunc: func() fixtures.KeyManager { +// panic("mock out the B method") +// }, +// CFunc: func(c fixtures.C) { +// panic("mock out the C method") +// }, +// } +// +// // use mockedImportsSameAsPackage in code that requires fixtures.ImportsSameAsPackage +// // and then make assertions. +// +// } +type ImportsSameAsPackage struct { + // AFunc mocks the A method. + AFunc func() redefinedtypeb.B + + // BFunc mocks the B method. + BFunc func() fixtures.KeyManager + + // CFunc mocks the C method. + CFunc func(c fixtures.C) + + // calls tracks calls to the methods. + calls struct { + // A holds details about calls to the A method. + A []struct { + } + // B holds details about calls to the B method. + B []struct { + } + // C holds details about calls to the C method. + C []struct { + // C is the c argument value. + C fixtures.C + } + } + lockA sync.RWMutex + lockB sync.RWMutex + lockC sync.RWMutex +} + +// A calls AFunc. +func (mock *ImportsSameAsPackage) A() redefinedtypeb.B { + if mock.AFunc == nil { + panic("ImportsSameAsPackage.AFunc: method is nil but ImportsSameAsPackage.A was just called") + } + callInfo := struct { + }{} + mock.lockA.Lock() + mock.calls.A = append(mock.calls.A, callInfo) + mock.lockA.Unlock() + return mock.AFunc() +} + +// ACalls gets all the calls that were made to A. +// Check the length with: +// +// len(mockedImportsSameAsPackage.ACalls()) +func (mock *ImportsSameAsPackage) ACalls() []struct { +} { + var calls []struct { + } + mock.lockA.RLock() + calls = mock.calls.A + mock.lockA.RUnlock() + return calls +} + +// B calls BFunc. +func (mock *ImportsSameAsPackage) B() fixtures.KeyManager { + if mock.BFunc == nil { + panic("ImportsSameAsPackage.BFunc: method is nil but ImportsSameAsPackage.B was just called") + } + callInfo := struct { + }{} + mock.lockB.Lock() + mock.calls.B = append(mock.calls.B, callInfo) + mock.lockB.Unlock() + return mock.BFunc() +} + +// BCalls gets all the calls that were made to B. +// Check the length with: +// +// len(mockedImportsSameAsPackage.BCalls()) +func (mock *ImportsSameAsPackage) BCalls() []struct { +} { + var calls []struct { + } + mock.lockB.RLock() + calls = mock.calls.B + mock.lockB.RUnlock() + return calls +} + +// C calls CFunc. +func (mock *ImportsSameAsPackage) C(c fixtures.C) { + if mock.CFunc == nil { + panic("ImportsSameAsPackage.CFunc: method is nil but ImportsSameAsPackage.C was just called") + } + callInfo := struct { + C fixtures.C + }{ + C: c, + } + mock.lockC.Lock() + mock.calls.C = append(mock.calls.C, callInfo) + mock.lockC.Unlock() + mock.CFunc(c) +} + +// CCalls gets all the calls that were made to C. +// Check the length with: +// +// len(mockedImportsSameAsPackage.CCalls()) +func (mock *ImportsSameAsPackage) CCalls() []struct { + C fixtures.C +} { + var calls []struct { + C fixtures.C + } + mock.lockC.RLock() + calls = mock.calls.C + mock.lockC.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go new file mode 100644 index 00000000..59bc5154 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go @@ -0,0 +1,82 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that KeyManager does implement test.KeyManager. +// If this is not the case, regenerate this file with moq. +var _ test.KeyManager = &KeyManager{} + +// KeyManager is a mock implementation of test.KeyManager. +// +// func TestSomethingThatUsesKeyManager(t *testing.T) { +// +// // make and configure a mocked test.KeyManager +// mockedKeyManager := &KeyManager{ +// GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { +// panic("mock out the GetKey method") +// }, +// } +// +// // use mockedKeyManager in code that requires test.KeyManager +// // and then make assertions. +// +// } +type KeyManager struct { + // GetKeyFunc mocks the GetKey method. + GetKeyFunc func(s string, v uint16) ([]byte, *test.Err) + + // calls tracks calls to the methods. + calls struct { + // GetKey holds details about calls to the GetKey method. + GetKey []struct { + // S is the s argument value. + S string + // V is the v argument value. + V uint16 + } + } + lockGetKey sync.RWMutex +} + +// GetKey calls GetKeyFunc. +func (mock *KeyManager) GetKey(s string, v uint16) ([]byte, *test.Err) { + if mock.GetKeyFunc == nil { + panic("KeyManager.GetKeyFunc: method is nil but KeyManager.GetKey was just called") + } + callInfo := struct { + S string + V uint16 + }{ + S: s, + V: v, + } + mock.lockGetKey.Lock() + mock.calls.GetKey = append(mock.calls.GetKey, callInfo) + mock.lockGetKey.Unlock() + return mock.GetKeyFunc(s, v) +} + +// GetKeyCalls gets all the calls that were made to GetKey. +// Check the length with: +// +// len(mockedKeyManager.GetKeyCalls()) +func (mock *KeyManager) GetKeyCalls() []struct { + S string + V uint16 +} { + var calls []struct { + S string + V uint16 + } + mock.lockGetKey.RLock() + calls = mock.calls.GetKey + mock.lockGetKey.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go new file mode 100644 index 00000000..f742b8e0 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that MapFunc does implement test.MapFunc. +// If this is not the case, regenerate this file with moq. +var _ test.MapFunc = &MapFunc{} + +// MapFunc is a mock implementation of test.MapFunc. +// +// func TestSomethingThatUsesMapFunc(t *testing.T) { +// +// // make and configure a mocked test.MapFunc +// mockedMapFunc := &MapFunc{ +// GetFunc: func(m map[string]func(string) string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedMapFunc in code that requires test.MapFunc +// // and then make assertions. +// +// } +type MapFunc struct { + // GetFunc mocks the Get method. + GetFunc func(m map[string]func(string) string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // M is the m argument value. + M map[string]func(string) string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *MapFunc) Get(m map[string]func(string) string) error { + if mock.GetFunc == nil { + panic("MapFunc.GetFunc: method is nil but MapFunc.Get was just called") + } + callInfo := struct { + M map[string]func(string) string + }{ + M: m, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(m) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedMapFunc.GetCalls()) +func (mock *MapFunc) GetCalls() []struct { + M map[string]func(string) string +} { + var calls []struct { + M map[string]func(string) string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go new file mode 100644 index 00000000..7cd5a2f1 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that MapToInterface does implement test.MapToInterface. +// If this is not the case, regenerate this file with moq. +var _ test.MapToInterface = &MapToInterface{} + +// MapToInterface is a mock implementation of test.MapToInterface. +// +// func TestSomethingThatUsesMapToInterface(t *testing.T) { +// +// // make and configure a mocked test.MapToInterface +// mockedMapToInterface := &MapToInterface{ +// FooFunc: func(arg1 ...map[string]interface{}) { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedMapToInterface in code that requires test.MapToInterface +// // and then make assertions. +// +// } +type MapToInterface struct { + // FooFunc mocks the Foo method. + FooFunc func(arg1 ...map[string]interface{}) + + // calls tracks calls to the methods. + calls struct { + // Foo holds details about calls to the Foo method. + Foo []struct { + // Arg1 is the arg1 argument value. + Arg1 []map[string]interface{} + } + } + lockFoo sync.RWMutex +} + +// Foo calls FooFunc. +func (mock *MapToInterface) Foo(arg1 ...map[string]interface{}) { + if mock.FooFunc == nil { + panic("MapToInterface.FooFunc: method is nil but MapToInterface.Foo was just called") + } + callInfo := struct { + Arg1 []map[string]interface{} + }{ + Arg1: arg1, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + mock.FooFunc(arg1...) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedMapToInterface.FooCalls()) +func (mock *MapToInterface) FooCalls() []struct { + Arg1 []map[string]interface{} +} { + var calls []struct { + Arg1 []map[string]interface{} + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go new file mode 100644 index 00000000..9b852377 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that MyReader does implement test.MyReader. +// If this is not the case, regenerate this file with moq. +var _ test.MyReader = &MyReader{} + +// MyReader is a mock implementation of test.MyReader. +// +// func TestSomethingThatUsesMyReader(t *testing.T) { +// +// // make and configure a mocked test.MyReader +// mockedMyReader := &MyReader{ +// ReadFunc: func(p []byte) (int, error) { +// panic("mock out the Read method") +// }, +// } +// +// // use mockedMyReader in code that requires test.MyReader +// // and then make assertions. +// +// } +type MyReader struct { + // ReadFunc mocks the Read method. + ReadFunc func(p []byte) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Read holds details about calls to the Read method. + Read []struct { + // P is the p argument value. + P []byte + } + } + lockRead sync.RWMutex +} + +// Read calls ReadFunc. +func (mock *MyReader) Read(p []byte) (int, error) { + if mock.ReadFunc == nil { + panic("MyReader.ReadFunc: method is nil but MyReader.Read was just called") + } + callInfo := struct { + P []byte + }{ + P: p, + } + mock.lockRead.Lock() + mock.calls.Read = append(mock.calls.Read, callInfo) + mock.lockRead.Unlock() + return mock.ReadFunc(p) +} + +// ReadCalls gets all the calls that were made to Read. +// Check the length with: +// +// len(mockedMyReader.ReadCalls()) +func (mock *MyReader) ReadCalls() []struct { + P []byte +} { + var calls []struct { + P []byte + } + mock.lockRead.RLock() + calls = mock.calls.Read + mock.lockRead.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go new file mode 100644 index 00000000..51935887 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that PanicOnNoReturnValue does implement test.PanicOnNoReturnValue. +// If this is not the case, regenerate this file with moq. +var _ test.PanicOnNoReturnValue = &PanicOnNoReturnValue{} + +// PanicOnNoReturnValue is a mock implementation of test.PanicOnNoReturnValue. +// +// func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { +// +// // make and configure a mocked test.PanicOnNoReturnValue +// mockedPanicOnNoReturnValue := &PanicOnNoReturnValue{ +// DoSomethingFunc: func() string { +// panic("mock out the DoSomething method") +// }, +// } +// +// // use mockedPanicOnNoReturnValue in code that requires test.PanicOnNoReturnValue +// // and then make assertions. +// +// } +type PanicOnNoReturnValue struct { + // DoSomethingFunc mocks the DoSomething method. + DoSomethingFunc func() string + + // calls tracks calls to the methods. + calls struct { + // DoSomething holds details about calls to the DoSomething method. + DoSomething []struct { + } + } + lockDoSomething sync.RWMutex +} + +// DoSomething calls DoSomethingFunc. +func (mock *PanicOnNoReturnValue) DoSomething() string { + if mock.DoSomethingFunc == nil { + panic("PanicOnNoReturnValue.DoSomethingFunc: method is nil but PanicOnNoReturnValue.DoSomething was just called") + } + callInfo := struct { + }{} + mock.lockDoSomething.Lock() + mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) + mock.lockDoSomething.Unlock() + return mock.DoSomethingFunc() +} + +// DoSomethingCalls gets all the calls that were made to DoSomething. +// Check the length with: +// +// len(mockedPanicOnNoReturnValue.DoSomethingCalls()) +func (mock *PanicOnNoReturnValue) DoSomethingCalls() []struct { +} { + var calls []struct { + } + mock.lockDoSomething.RLock() + calls = mock.calls.DoSomething + mock.lockDoSomething.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go new file mode 100644 index 00000000..2ab5c70f --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Requester does implement test.Requester. +// If this is not the case, regenerate this file with moq. +var _ test.Requester = &Requester{} + +// Requester is a mock implementation of test.Requester. +// +// func TestSomethingThatUsesRequester(t *testing.T) { +// +// // make and configure a mocked test.Requester +// mockedRequester := &Requester{ +// GetFunc: func(path string) (string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester in code that requires test.Requester +// // and then make assertions. +// +// } +type Requester struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester) Get(path string) (string, error) { + if mock.GetFunc == nil { + panic("Requester.GetFunc: method is nil but Requester.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester.GetCalls()) +func (mock *Requester) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go new file mode 100644 index 00000000..f6a423ad --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Requester2 does implement test.Requester2. +// If this is not the case, regenerate this file with moq. +var _ test.Requester2 = &Requester2{} + +// Requester2 is a mock implementation of test.Requester2. +// +// func TestSomethingThatUsesRequester2(t *testing.T) { +// +// // make and configure a mocked test.Requester2 +// mockedRequester2 := &Requester2{ +// GetFunc: func(path string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester2 in code that requires test.Requester2 +// // and then make assertions. +// +// } +type Requester2 struct { + // GetFunc mocks the Get method. + GetFunc func(path string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester2) Get(path string) error { + if mock.GetFunc == nil { + panic("Requester2.GetFunc: method is nil but Requester2.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester2.GetCalls()) +func (mock *Requester2) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go new file mode 100644 index 00000000..ff14672e --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Requester3 does implement test.Requester3. +// If this is not the case, regenerate this file with moq. +var _ test.Requester3 = &Requester3{} + +// Requester3 is a mock implementation of test.Requester3. +// +// func TestSomethingThatUsesRequester3(t *testing.T) { +// +// // make and configure a mocked test.Requester3 +// mockedRequester3 := &Requester3{ +// GetFunc: func() error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester3 in code that requires test.Requester3 +// // and then make assertions. +// +// } +type Requester3 struct { + // GetFunc mocks the Get method. + GetFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester3) Get() error { + if mock.GetFunc == nil { + panic("Requester3.GetFunc: method is nil but Requester3.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester3.GetCalls()) +func (mock *Requester3) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go new file mode 100644 index 00000000..2e40a741 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Requester4 does implement test.Requester4. +// If this is not the case, regenerate this file with moq. +var _ test.Requester4 = &Requester4{} + +// Requester4 is a mock implementation of test.Requester4. +// +// func TestSomethingThatUsesRequester4(t *testing.T) { +// +// // make and configure a mocked test.Requester4 +// mockedRequester4 := &Requester4{ +// GetFunc: func() { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester4 in code that requires test.Requester4 +// // and then make assertions. +// +// } +type Requester4 struct { + // GetFunc mocks the Get method. + GetFunc func() + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester4) Get() { + if mock.GetFunc == nil { + panic("Requester4.GetFunc: method is nil but Requester4.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester4.GetCalls()) +func (mock *Requester4) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go new file mode 100644 index 00000000..35db68db --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go @@ -0,0 +1,77 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "encoding/json" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterArgSameAsImport does implement test.RequesterArgSameAsImport. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterArgSameAsImport = &RequesterArgSameAsImport{} + +// RequesterArgSameAsImport is a mock implementation of test.RequesterArgSameAsImport. +// +// func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { +// +// // make and configure a mocked test.RequesterArgSameAsImport +// mockedRequesterArgSameAsImport := &RequesterArgSameAsImport{ +// GetFunc: func(jsonMoqParam string) *json.RawMessage { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsImport in code that requires test.RequesterArgSameAsImport +// // and then make assertions. +// +// } +type RequesterArgSameAsImport struct { + // GetFunc mocks the Get method. + GetFunc func(jsonMoqParam string) *json.RawMessage + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // JsonMoqParam is the jsonMoqParam argument value. + JsonMoqParam string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsImport) Get(jsonMoqParam string) *json.RawMessage { + if mock.GetFunc == nil { + panic("RequesterArgSameAsImport.GetFunc: method is nil but RequesterArgSameAsImport.Get was just called") + } + callInfo := struct { + JsonMoqParam string + }{ + JsonMoqParam: jsonMoqParam, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(jsonMoqParam) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsImport.GetCalls()) +func (mock *RequesterArgSameAsImport) GetCalls() []struct { + JsonMoqParam string +} { + var calls []struct { + JsonMoqParam string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go new file mode 100644 index 00000000..528a7aa5 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go @@ -0,0 +1,77 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "encoding/json" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterArgSameAsNamedImport does implement test.RequesterArgSameAsNamedImport. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterArgSameAsNamedImport = &RequesterArgSameAsNamedImport{} + +// RequesterArgSameAsNamedImport is a mock implementation of test.RequesterArgSameAsNamedImport. +// +// func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { +// +// // make and configure a mocked test.RequesterArgSameAsNamedImport +// mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImport{ +// GetFunc: func(jsonMoqParam string) *json.RawMessage { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsNamedImport in code that requires test.RequesterArgSameAsNamedImport +// // and then make assertions. +// +// } +type RequesterArgSameAsNamedImport struct { + // GetFunc mocks the Get method. + GetFunc func(jsonMoqParam string) *json.RawMessage + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // JsonMoqParam is the jsonMoqParam argument value. + JsonMoqParam string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsNamedImport) Get(jsonMoqParam string) *json.RawMessage { + if mock.GetFunc == nil { + panic("RequesterArgSameAsNamedImport.GetFunc: method is nil but RequesterArgSameAsNamedImport.Get was just called") + } + callInfo := struct { + JsonMoqParam string + }{ + JsonMoqParam: jsonMoqParam, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(jsonMoqParam) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsNamedImport.GetCalls()) +func (mock *RequesterArgSameAsNamedImport) GetCalls() []struct { + JsonMoqParam string +} { + var calls []struct { + JsonMoqParam string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go new file mode 100644 index 00000000..661fe591 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterArgSameAsPkg does implement test.RequesterArgSameAsPkg. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterArgSameAsPkg = &RequesterArgSameAsPkg{} + +// RequesterArgSameAsPkg is a mock implementation of test.RequesterArgSameAsPkg. +// +// func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { +// +// // make and configure a mocked test.RequesterArgSameAsPkg +// mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkg{ +// GetFunc: func(test string) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsPkg in code that requires test.RequesterArgSameAsPkg +// // and then make assertions. +// +// } +type RequesterArgSameAsPkg struct { + // GetFunc mocks the Get method. + GetFunc func(test string) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Test is the test argument value. + Test string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsPkg) Get(test string) { + if mock.GetFunc == nil { + panic("RequesterArgSameAsPkg.GetFunc: method is nil but RequesterArgSameAsPkg.Get was just called") + } + callInfo := struct { + Test string + }{ + Test: test, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + mock.GetFunc(test) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsPkg.GetCalls()) +func (mock *RequesterArgSameAsPkg) GetCalls() []struct { + Test string +} { + var calls []struct { + Test string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go new file mode 100644 index 00000000..6d973fa6 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterArray does implement test.RequesterArray. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterArray = &RequesterArray{} + +// RequesterArray is a mock implementation of test.RequesterArray. +// +// func TestSomethingThatUsesRequesterArray(t *testing.T) { +// +// // make and configure a mocked test.RequesterArray +// mockedRequesterArray := &RequesterArray{ +// GetFunc: func(path string) ([2]string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArray in code that requires test.RequesterArray +// // and then make assertions. +// +// } +type RequesterArray struct { + // GetFunc mocks the Get method. + GetFunc func(path string) ([2]string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArray) Get(path string) ([2]string, error) { + if mock.GetFunc == nil { + panic("RequesterArray.GetFunc: method is nil but RequesterArray.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArray.GetCalls()) +func (mock *RequesterArray) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go new file mode 100644 index 00000000..d6bb8911 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go @@ -0,0 +1,82 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterElided does implement test.RequesterElided. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterElided = &RequesterElided{} + +// RequesterElided is a mock implementation of test.RequesterElided. +// +// func TestSomethingThatUsesRequesterElided(t *testing.T) { +// +// // make and configure a mocked test.RequesterElided +// mockedRequesterElided := &RequesterElided{ +// GetFunc: func(path string, url string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterElided in code that requires test.RequesterElided +// // and then make assertions. +// +// } +type RequesterElided struct { + // GetFunc mocks the Get method. + GetFunc func(path string, url string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + // URL is the url argument value. + URL string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterElided) Get(path string, url string) error { + if mock.GetFunc == nil { + panic("RequesterElided.GetFunc: method is nil but RequesterElided.Get was just called") + } + callInfo := struct { + Path string + URL string + }{ + Path: path, + URL: url, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path, url) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterElided.GetCalls()) +func (mock *RequesterElided) GetCalls() []struct { + Path string + URL string +} { + var calls []struct { + Path string + URL string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go new file mode 100644 index 00000000..e27ec417 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go @@ -0,0 +1,179 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "io" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that RequesterGenerics does implement test.RequesterGenerics. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int] = &RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int]{} + +// RequesterGenerics is a mock implementation of test.RequesterGenerics. +// +// func TestSomethingThatUsesRequesterGenerics(t *testing.T) { +// +// // make and configure a mocked test.RequesterGenerics +// mockedRequesterGenerics := &RequesterGenerics{ +// GenericAnonymousStructsFunc: func(val struct{Type1 TExternalIntf}) struct{Type2 test.GenericType[string, test.EmbeddedGet[int]]} { +// panic("mock out the GenericAnonymousStructs method") +// }, +// GenericArgumentsFunc: func(v1 TAny, v2 TComparable) (TSigned, TIntf) { +// panic("mock out the GenericArguments method") +// }, +// GenericStructsFunc: func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { +// panic("mock out the GenericStructs method") +// }, +// } +// +// // use mockedRequesterGenerics in code that requires test.RequesterGenerics +// // and then make assertions. +// +// } +type RequesterGenerics[TAny any, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { + ~int | GenericType[int, GetInt] + comparable +}] struct { + // GenericAnonymousStructsFunc mocks the GenericAnonymousStructs method. + GenericAnonymousStructsFunc func(val struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] + } + + // GenericArgumentsFunc mocks the GenericArguments method. + GenericArgumentsFunc func(v1 TAny, v2 TComparable) (TSigned, TIntf) + + // GenericStructsFunc mocks the GenericStructs method. + GenericStructsFunc func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] + + // calls tracks calls to the methods. + calls struct { + // GenericAnonymousStructs holds details about calls to the GenericAnonymousStructs method. + GenericAnonymousStructs []struct { + // Val is the val argument value. + Val struct{ Type1 TExternalIntf } + } + // GenericArguments holds details about calls to the GenericArguments method. + GenericArguments []struct { + // V1 is the v1 argument value. + V1 TAny + // V2 is the v2 argument value. + V2 TComparable + } + // GenericStructs holds details about calls to the GenericStructs method. + GenericStructs []struct { + // GenericType is the genericType argument value. + GenericType test.GenericType[TAny, TIntf] + } + } + lockGenericAnonymousStructs sync.RWMutex + lockGenericArguments sync.RWMutex + lockGenericStructs sync.RWMutex +} + +// GenericAnonymousStructs calls GenericAnonymousStructsFunc. +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructs(val struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] +} { + if mock.GenericAnonymousStructsFunc == nil { + panic("RequesterGenerics.GenericAnonymousStructsFunc: method is nil but RequesterGenerics.GenericAnonymousStructs was just called") + } + callInfo := struct { + Val struct{ Type1 TExternalIntf } + }{ + Val: val, + } + mock.lockGenericAnonymousStructs.Lock() + mock.calls.GenericAnonymousStructs = append(mock.calls.GenericAnonymousStructs, callInfo) + mock.lockGenericAnonymousStructs.Unlock() + return mock.GenericAnonymousStructsFunc(val) +} + +// GenericAnonymousStructsCalls gets all the calls that were made to GenericAnonymousStructs. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericAnonymousStructsCalls()) +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructsCalls() []struct { + Val struct{ Type1 TExternalIntf } +} { + var calls []struct { + Val struct{ Type1 TExternalIntf } + } + mock.lockGenericAnonymousStructs.RLock() + calls = mock.calls.GenericAnonymousStructs + mock.lockGenericAnonymousStructs.RUnlock() + return calls +} + +// GenericArguments calls GenericArgumentsFunc. +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArguments(v1 TAny, v2 TComparable) (TSigned, TIntf) { + if mock.GenericArgumentsFunc == nil { + panic("RequesterGenerics.GenericArgumentsFunc: method is nil but RequesterGenerics.GenericArguments was just called") + } + callInfo := struct { + V1 TAny + V2 TComparable + }{ + V1: v1, + V2: v2, + } + mock.lockGenericArguments.Lock() + mock.calls.GenericArguments = append(mock.calls.GenericArguments, callInfo) + mock.lockGenericArguments.Unlock() + return mock.GenericArgumentsFunc(v1, v2) +} + +// GenericArgumentsCalls gets all the calls that were made to GenericArguments. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericArgumentsCalls()) +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArgumentsCalls() []struct { + V1 TAny + V2 TComparable +} { + var calls []struct { + V1 TAny + V2 TComparable + } + mock.lockGenericArguments.RLock() + calls = mock.calls.GenericArguments + mock.lockGenericArguments.RUnlock() + return calls +} + +// GenericStructs calls GenericStructsFunc. +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructs(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { + if mock.GenericStructsFunc == nil { + panic("RequesterGenerics.GenericStructsFunc: method is nil but RequesterGenerics.GenericStructs was just called") + } + callInfo := struct { + GenericType test.GenericType[TAny, TIntf] + }{ + GenericType: genericType, + } + mock.lockGenericStructs.Lock() + mock.calls.GenericStructs = append(mock.calls.GenericStructs, callInfo) + mock.lockGenericStructs.Unlock() + return mock.GenericStructsFunc(genericType) +} + +// GenericStructsCalls gets all the calls that were made to GenericStructs. +// Check the length with: +// +// len(mockedRequesterGenerics.GenericStructsCalls()) +func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructsCalls() []struct { + GenericType test.GenericType[TAny, TIntf] +} { + var calls []struct { + GenericType test.GenericType[TAny, TIntf] + } + mock.lockGenericStructs.RLock() + calls = mock.calls.GenericStructs + mock.lockGenericStructs.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go new file mode 100644 index 00000000..6040e2c5 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go @@ -0,0 +1,70 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "io" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterIface does implement test.RequesterIface. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterIface = &RequesterIface{} + +// RequesterIface is a mock implementation of test.RequesterIface. +// +// func TestSomethingThatUsesRequesterIface(t *testing.T) { +// +// // make and configure a mocked test.RequesterIface +// mockedRequesterIface := &RequesterIface{ +// GetFunc: func() io.Reader { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterIface in code that requires test.RequesterIface +// // and then make assertions. +// +// } +type RequesterIface struct { + // GetFunc mocks the Get method. + GetFunc func() io.Reader + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterIface) Get() io.Reader { + if mock.GetFunc == nil { + panic("RequesterIface.GetFunc: method is nil but RequesterIface.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterIface.GetCalls()) +func (mock *RequesterIface) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go new file mode 100644 index 00000000..1853f7b9 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go @@ -0,0 +1,77 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "net/http" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterNS does implement test.RequesterNS. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterNS = &RequesterNS{} + +// RequesterNS is a mock implementation of test.RequesterNS. +// +// func TestSomethingThatUsesRequesterNS(t *testing.T) { +// +// // make and configure a mocked test.RequesterNS +// mockedRequesterNS := &RequesterNS{ +// GetFunc: func(path string) (http.Response, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterNS in code that requires test.RequesterNS +// // and then make assertions. +// +// } +type RequesterNS struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (http.Response, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterNS) Get(path string) (http.Response, error) { + if mock.GetFunc == nil { + panic("RequesterNS.GetFunc: method is nil but RequesterNS.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterNS.GetCalls()) +func (mock *RequesterNS) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go new file mode 100644 index 00000000..7e98f69c --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterPtr does implement test.RequesterPtr. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterPtr = &RequesterPtr{} + +// RequesterPtr is a mock implementation of test.RequesterPtr. +// +// func TestSomethingThatUsesRequesterPtr(t *testing.T) { +// +// // make and configure a mocked test.RequesterPtr +// mockedRequesterPtr := &RequesterPtr{ +// GetFunc: func(path string) (*string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterPtr in code that requires test.RequesterPtr +// // and then make assertions. +// +// } +type RequesterPtr struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (*string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterPtr) Get(path string) (*string, error) { + if mock.GetFunc == nil { + panic("RequesterPtr.GetFunc: method is nil but RequesterPtr.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterPtr.GetCalls()) +func (mock *RequesterPtr) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go new file mode 100644 index 00000000..3fed3c3f --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go @@ -0,0 +1,120 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterReturnElided does implement test.RequesterReturnElided. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterReturnElided = &RequesterReturnElided{} + +// RequesterReturnElided is a mock implementation of test.RequesterReturnElided. +// +// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { +// +// // make and configure a mocked test.RequesterReturnElided +// mockedRequesterReturnElided := &RequesterReturnElided{ +// GetFunc: func(path string) (int, int, int, error) { +// panic("mock out the Get method") +// }, +// PutFunc: func(path string) (int, error) { +// panic("mock out the Put method") +// }, +// } +// +// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided +// // and then make assertions. +// +// } +type RequesterReturnElided struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (int, int, int, error) + + // PutFunc mocks the Put method. + PutFunc func(path string) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Put holds details about calls to the Put method. + Put []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex + lockPut sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterReturnElided) Get(path string) (int, int, int, error) { + if mock.GetFunc == nil { + panic("RequesterReturnElided.GetFunc: method is nil but RequesterReturnElided.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterReturnElided.GetCalls()) +func (mock *RequesterReturnElided) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// Put calls PutFunc. +func (mock *RequesterReturnElided) Put(path string) (int, error) { + if mock.PutFunc == nil { + panic("RequesterReturnElided.PutFunc: method is nil but RequesterReturnElided.Put was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockPut.Lock() + mock.calls.Put = append(mock.calls.Put, callInfo) + mock.lockPut.Unlock() + return mock.PutFunc(path) +} + +// PutCalls gets all the calls that were made to Put. +// Check the length with: +// +// len(mockedRequesterReturnElided.PutCalls()) +func (mock *RequesterReturnElided) PutCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockPut.RLock() + calls = mock.calls.Put + mock.lockPut.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go new file mode 100644 index 00000000..a55b94ab --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterSlice does implement test.RequesterSlice. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterSlice = &RequesterSlice{} + +// RequesterSlice is a mock implementation of test.RequesterSlice. +// +// func TestSomethingThatUsesRequesterSlice(t *testing.T) { +// +// // make and configure a mocked test.RequesterSlice +// mockedRequesterSlice := &RequesterSlice{ +// GetFunc: func(path string) ([]string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterSlice in code that requires test.RequesterSlice +// // and then make assertions. +// +// } +type RequesterSlice struct { + // GetFunc mocks the Get method. + GetFunc func(path string) ([]string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterSlice) Get(path string) ([]string, error) { + if mock.GetFunc == nil { + panic("RequesterSlice.GetFunc: method is nil but RequesterSlice.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterSlice.GetCalls()) +func (mock *RequesterSlice) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go new file mode 100644 index 00000000..9be735df --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go @@ -0,0 +1,221 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "io" + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that RequesterVariadic does implement test.RequesterVariadic. +// If this is not the case, regenerate this file with moq. +var _ test.RequesterVariadic = &RequesterVariadic{} + +// RequesterVariadic is a mock implementation of test.RequesterVariadic. +// +// func TestSomethingThatUsesRequesterVariadic(t *testing.T) { +// +// // make and configure a mocked test.RequesterVariadic +// mockedRequesterVariadic := &RequesterVariadic{ +// GetFunc: func(values ...string) bool { +// panic("mock out the Get method") +// }, +// MultiWriteToFileFunc: func(filename string, w ...io.Writer) string { +// panic("mock out the MultiWriteToFile method") +// }, +// OneInterfaceFunc: func(a ...interface{}) bool { +// panic("mock out the OneInterface method") +// }, +// SprintfFunc: func(format string, a ...interface{}) string { +// panic("mock out the Sprintf method") +// }, +// } +// +// // use mockedRequesterVariadic in code that requires test.RequesterVariadic +// // and then make assertions. +// +// } +type RequesterVariadic struct { + // GetFunc mocks the Get method. + GetFunc func(values ...string) bool + + // MultiWriteToFileFunc mocks the MultiWriteToFile method. + MultiWriteToFileFunc func(filename string, w ...io.Writer) string + + // OneInterfaceFunc mocks the OneInterface method. + OneInterfaceFunc func(a ...interface{}) bool + + // SprintfFunc mocks the Sprintf method. + SprintfFunc func(format string, a ...interface{}) string + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Values is the values argument value. + Values []string + } + // MultiWriteToFile holds details about calls to the MultiWriteToFile method. + MultiWriteToFile []struct { + // Filename is the filename argument value. + Filename string + // W is the w argument value. + W []io.Writer + } + // OneInterface holds details about calls to the OneInterface method. + OneInterface []struct { + // A is the a argument value. + A []interface{} + } + // Sprintf holds details about calls to the Sprintf method. + Sprintf []struct { + // Format is the format argument value. + Format string + // A is the a argument value. + A []interface{} + } + } + lockGet sync.RWMutex + lockMultiWriteToFile sync.RWMutex + lockOneInterface sync.RWMutex + lockSprintf sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterVariadic) Get(values ...string) bool { + if mock.GetFunc == nil { + panic("RequesterVariadic.GetFunc: method is nil but RequesterVariadic.Get was just called") + } + callInfo := struct { + Values []string + }{ + Values: values, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(values...) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterVariadic.GetCalls()) +func (mock *RequesterVariadic) GetCalls() []struct { + Values []string +} { + var calls []struct { + Values []string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// MultiWriteToFile calls MultiWriteToFileFunc. +func (mock *RequesterVariadic) MultiWriteToFile(filename string, w ...io.Writer) string { + if mock.MultiWriteToFileFunc == nil { + panic("RequesterVariadic.MultiWriteToFileFunc: method is nil but RequesterVariadic.MultiWriteToFile was just called") + } + callInfo := struct { + Filename string + W []io.Writer + }{ + Filename: filename, + W: w, + } + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = append(mock.calls.MultiWriteToFile, callInfo) + mock.lockMultiWriteToFile.Unlock() + return mock.MultiWriteToFileFunc(filename, w...) +} + +// MultiWriteToFileCalls gets all the calls that were made to MultiWriteToFile. +// Check the length with: +// +// len(mockedRequesterVariadic.MultiWriteToFileCalls()) +func (mock *RequesterVariadic) MultiWriteToFileCalls() []struct { + Filename string + W []io.Writer +} { + var calls []struct { + Filename string + W []io.Writer + } + mock.lockMultiWriteToFile.RLock() + calls = mock.calls.MultiWriteToFile + mock.lockMultiWriteToFile.RUnlock() + return calls +} + +// OneInterface calls OneInterfaceFunc. +func (mock *RequesterVariadic) OneInterface(a ...interface{}) bool { + if mock.OneInterfaceFunc == nil { + panic("RequesterVariadic.OneInterfaceFunc: method is nil but RequesterVariadic.OneInterface was just called") + } + callInfo := struct { + A []interface{} + }{ + A: a, + } + mock.lockOneInterface.Lock() + mock.calls.OneInterface = append(mock.calls.OneInterface, callInfo) + mock.lockOneInterface.Unlock() + return mock.OneInterfaceFunc(a...) +} + +// OneInterfaceCalls gets all the calls that were made to OneInterface. +// Check the length with: +// +// len(mockedRequesterVariadic.OneInterfaceCalls()) +func (mock *RequesterVariadic) OneInterfaceCalls() []struct { + A []interface{} +} { + var calls []struct { + A []interface{} + } + mock.lockOneInterface.RLock() + calls = mock.calls.OneInterface + mock.lockOneInterface.RUnlock() + return calls +} + +// Sprintf calls SprintfFunc. +func (mock *RequesterVariadic) Sprintf(format string, a ...interface{}) string { + if mock.SprintfFunc == nil { + panic("RequesterVariadic.SprintfFunc: method is nil but RequesterVariadic.Sprintf was just called") + } + callInfo := struct { + Format string + A []interface{} + }{ + Format: format, + A: a, + } + mock.lockSprintf.Lock() + mock.calls.Sprintf = append(mock.calls.Sprintf, callInfo) + mock.lockSprintf.Unlock() + return mock.SprintfFunc(format, a...) +} + +// SprintfCalls gets all the calls that were made to Sprintf. +// Check the length with: +// +// len(mockedRequesterVariadic.SprintfCalls()) +func (mock *RequesterVariadic) SprintfCalls() []struct { + Format string + A []interface{} +} { + var calls []struct { + Format string + A []interface{} + } + mock.lockSprintf.RLock() + calls = mock.calls.Sprintf + mock.lockSprintf.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go new file mode 100644 index 00000000..08e5e4a5 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go @@ -0,0 +1,69 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Sibling does implement test.Sibling. +// If this is not the case, regenerate this file with moq. +var _ test.Sibling = &Sibling{} + +// Sibling is a mock implementation of test.Sibling. +// +// func TestSomethingThatUsesSibling(t *testing.T) { +// +// // make and configure a mocked test.Sibling +// mockedSibling := &Sibling{ +// DoSomethingFunc: func() { +// panic("mock out the DoSomething method") +// }, +// } +// +// // use mockedSibling in code that requires test.Sibling +// // and then make assertions. +// +// } +type Sibling struct { + // DoSomethingFunc mocks the DoSomething method. + DoSomethingFunc func() + + // calls tracks calls to the methods. + calls struct { + // DoSomething holds details about calls to the DoSomething method. + DoSomething []struct { + } + } + lockDoSomething sync.RWMutex +} + +// DoSomething calls DoSomethingFunc. +func (mock *Sibling) DoSomething() { + if mock.DoSomethingFunc == nil { + panic("Sibling.DoSomethingFunc: method is nil but Sibling.DoSomething was just called") + } + callInfo := struct { + }{} + mock.lockDoSomething.Lock() + mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) + mock.lockDoSomething.Unlock() + mock.DoSomethingFunc() +} + +// DoSomethingCalls gets all the calls that were made to DoSomething. +// Check the length with: +// +// len(mockedSibling.DoSomethingCalls()) +func (mock *Sibling) DoSomethingCalls() []struct { +} { + var calls []struct { + } + mock.lockDoSomething.RLock() + calls = mock.calls.DoSomething + mock.lockDoSomething.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go new file mode 100644 index 00000000..b3967ef6 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go @@ -0,0 +1,100 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that StructWithTag does implement test.StructWithTag. +// If this is not the case, regenerate this file with moq. +var _ test.StructWithTag = &StructWithTag{} + +// StructWithTag is a mock implementation of test.StructWithTag. +// +// func TestSomethingThatUsesStructWithTag(t *testing.T) { +// +// // make and configure a mocked test.StructWithTag +// mockedStructWithTag := &StructWithTag{ +// MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { +// panic("mock out the MethodA method") +// }, +// } +// +// // use mockedStructWithTag in code that requires test.StructWithTag +// // and then make assertions. +// +// } +type StructWithTag struct { + // MethodAFunc mocks the MethodA method. + MethodAFunc func(v *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + }) *struct { + FieldC int "json:\"field_c\"" + FieldD int "json:\"field_d\" xml:\"field_d\"" + } + + // calls tracks calls to the methods. + calls struct { + // MethodA holds details about calls to the MethodA method. + MethodA []struct { + // V is the v argument value. + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + } + } + lockMethodA sync.RWMutex +} + +// MethodA calls MethodAFunc. +func (mock *StructWithTag) MethodA(v *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" +}) *struct { + FieldC int "json:\"field_c\"" + FieldD int "json:\"field_d\" xml:\"field_d\"" +} { + if mock.MethodAFunc == nil { + panic("StructWithTag.MethodAFunc: method is nil but StructWithTag.MethodA was just called") + } + callInfo := struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + }{ + V: v, + } + mock.lockMethodA.Lock() + mock.calls.MethodA = append(mock.calls.MethodA, callInfo) + mock.lockMethodA.Unlock() + return mock.MethodAFunc(v) +} + +// MethodACalls gets all the calls that were made to MethodA. +// Check the length with: +// +// len(mockedStructWithTag.MethodACalls()) +func (mock *StructWithTag) MethodACalls() []struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } +} { + var calls []struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + } + mock.lockMethodA.RLock() + calls = mock.calls.MethodA + mock.lockMethodA.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go new file mode 100644 index 00000000..d58735c9 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that UnsafeInterface does implement test.UnsafeInterface. +// If this is not the case, regenerate this file with moq. +var _ test.UnsafeInterface = &UnsafeInterface{} + +// UnsafeInterface is a mock implementation of test.UnsafeInterface. +// +// func TestSomethingThatUsesUnsafeInterface(t *testing.T) { +// +// // make and configure a mocked test.UnsafeInterface +// mockedUnsafeInterface := &UnsafeInterface{ +// DoFunc: func(ptr *Pointer) { +// panic("mock out the Do method") +// }, +// } +// +// // use mockedUnsafeInterface in code that requires test.UnsafeInterface +// // and then make assertions. +// +// } +type UnsafeInterface struct { + // DoFunc mocks the Do method. + DoFunc func(ptr *Pointer) + + // calls tracks calls to the methods. + calls struct { + // Do holds details about calls to the Do method. + Do []struct { + // Ptr is the ptr argument value. + Ptr *Pointer + } + } + lockDo sync.RWMutex +} + +// Do calls DoFunc. +func (mock *UnsafeInterface) Do(ptr *Pointer) { + if mock.DoFunc == nil { + panic("UnsafeInterface.DoFunc: method is nil but UnsafeInterface.Do was just called") + } + callInfo := struct { + Ptr *Pointer + }{ + Ptr: ptr, + } + mock.lockDo.Lock() + mock.calls.Do = append(mock.calls.Do, callInfo) + mock.lockDo.Unlock() + mock.DoFunc(ptr) +} + +// DoCalls gets all the calls that were made to Do. +// Check the length with: +// +// len(mockedUnsafeInterface.DoCalls()) +func (mock *UnsafeInterface) DoCalls() []struct { + Ptr *Pointer +} { + var calls []struct { + Ptr *Pointer + } + mock.lockDo.RLock() + calls = mock.calls.Do + mock.lockDo.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go new file mode 100644 index 00000000..f0690460 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that UsesOtherPkgIface does implement test.UsesOtherPkgIface. +// If this is not the case, regenerate this file with moq. +var _ test.UsesOtherPkgIface = &UsesOtherPkgIface{} + +// UsesOtherPkgIface is a mock implementation of test.UsesOtherPkgIface. +// +// func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { +// +// // make and configure a mocked test.UsesOtherPkgIface +// mockedUsesOtherPkgIface := &UsesOtherPkgIface{ +// DoSomethingElseFunc: func(obj test.Sibling) { +// panic("mock out the DoSomethingElse method") +// }, +// } +// +// // use mockedUsesOtherPkgIface in code that requires test.UsesOtherPkgIface +// // and then make assertions. +// +// } +type UsesOtherPkgIface struct { + // DoSomethingElseFunc mocks the DoSomethingElse method. + DoSomethingElseFunc func(obj test.Sibling) + + // calls tracks calls to the methods. + calls struct { + // DoSomethingElse holds details about calls to the DoSomethingElse method. + DoSomethingElse []struct { + // Obj is the obj argument value. + Obj test.Sibling + } + } + lockDoSomethingElse sync.RWMutex +} + +// DoSomethingElse calls DoSomethingElseFunc. +func (mock *UsesOtherPkgIface) DoSomethingElse(obj test.Sibling) { + if mock.DoSomethingElseFunc == nil { + panic("UsesOtherPkgIface.DoSomethingElseFunc: method is nil but UsesOtherPkgIface.DoSomethingElse was just called") + } + callInfo := struct { + Obj test.Sibling + }{ + Obj: obj, + } + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = append(mock.calls.DoSomethingElse, callInfo) + mock.lockDoSomethingElse.Unlock() + mock.DoSomethingElseFunc(obj) +} + +// DoSomethingElseCalls gets all the calls that were made to DoSomethingElse. +// Check the length with: +// +// len(mockedUsesOtherPkgIface.DoSomethingElseCalls()) +func (mock *UsesOtherPkgIface) DoSomethingElseCalls() []struct { + Obj test.Sibling +} { + var calls []struct { + Obj test.Sibling + } + mock.lockDoSomethingElse.RLock() + calls = mock.calls.DoSomethingElse + mock.lockDoSomethingElse.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go new file mode 100644 index 00000000..f148907e --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go @@ -0,0 +1,82 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that Variadic does implement test.Variadic. +// If this is not the case, regenerate this file with moq. +var _ test.Variadic = &Variadic{} + +// Variadic is a mock implementation of test.Variadic. +// +// func TestSomethingThatUsesVariadic(t *testing.T) { +// +// // make and configure a mocked test.Variadic +// mockedVariadic := &Variadic{ +// VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { +// panic("mock out the VariadicFunction method") +// }, +// } +// +// // use mockedVariadic in code that requires test.Variadic +// // and then make assertions. +// +// } +type Variadic struct { + // VariadicFunctionFunc mocks the VariadicFunction method. + VariadicFunctionFunc func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error + + // calls tracks calls to the methods. + calls struct { + // VariadicFunction holds details about calls to the VariadicFunction method. + VariadicFunction []struct { + // Str is the str argument value. + Str string + // VFunc is the vFunc argument value. + VFunc func(args1 string, args2 ...interface{}) interface{} + } + } + lockVariadicFunction sync.RWMutex +} + +// VariadicFunction calls VariadicFunctionFunc. +func (mock *Variadic) VariadicFunction(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { + if mock.VariadicFunctionFunc == nil { + panic("Variadic.VariadicFunctionFunc: method is nil but Variadic.VariadicFunction was just called") + } + callInfo := struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} + }{ + Str: str, + VFunc: vFunc, + } + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = append(mock.calls.VariadicFunction, callInfo) + mock.lockVariadicFunction.Unlock() + return mock.VariadicFunctionFunc(str, vFunc) +} + +// VariadicFunctionCalls gets all the calls that were made to VariadicFunction. +// Check the length with: +// +// len(mockedVariadic.VariadicFunctionCalls()) +func (mock *Variadic) VariadicFunctionCalls() []struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} +} { + var calls []struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} + } + mock.lockVariadicFunction.RLock() + calls = mock.calls.VariadicFunction + mock.lockVariadicFunction.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go new file mode 100644 index 00000000..ed2e3d6d --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go @@ -0,0 +1,82 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that VariadicNoReturnInterface does implement test.VariadicNoReturnInterface. +// If this is not the case, regenerate this file with moq. +var _ test.VariadicNoReturnInterface = &VariadicNoReturnInterface{} + +// VariadicNoReturnInterface is a mock implementation of test.VariadicNoReturnInterface. +// +// func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { +// +// // make and configure a mocked test.VariadicNoReturnInterface +// mockedVariadicNoReturnInterface := &VariadicNoReturnInterface{ +// VariadicNoReturnFunc: func(j int, is ...interface{}) { +// panic("mock out the VariadicNoReturn method") +// }, +// } +// +// // use mockedVariadicNoReturnInterface in code that requires test.VariadicNoReturnInterface +// // and then make assertions. +// +// } +type VariadicNoReturnInterface struct { + // VariadicNoReturnFunc mocks the VariadicNoReturn method. + VariadicNoReturnFunc func(j int, is ...interface{}) + + // calls tracks calls to the methods. + calls struct { + // VariadicNoReturn holds details about calls to the VariadicNoReturn method. + VariadicNoReturn []struct { + // J is the j argument value. + J int + // Is is the is argument value. + Is []interface{} + } + } + lockVariadicNoReturn sync.RWMutex +} + +// VariadicNoReturn calls VariadicNoReturnFunc. +func (mock *VariadicNoReturnInterface) VariadicNoReturn(j int, is ...interface{}) { + if mock.VariadicNoReturnFunc == nil { + panic("VariadicNoReturnInterface.VariadicNoReturnFunc: method is nil but VariadicNoReturnInterface.VariadicNoReturn was just called") + } + callInfo := struct { + J int + Is []interface{} + }{ + J: j, + Is: is, + } + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = append(mock.calls.VariadicNoReturn, callInfo) + mock.lockVariadicNoReturn.Unlock() + mock.VariadicNoReturnFunc(j, is...) +} + +// VariadicNoReturnCalls gets all the calls that were made to VariadicNoReturn. +// Check the length with: +// +// len(mockedVariadicNoReturnInterface.VariadicNoReturnCalls()) +func (mock *VariadicNoReturnInterface) VariadicNoReturnCalls() []struct { + J int + Is []interface{} +} { + var calls []struct { + J int + Is []interface{} + } + mock.lockVariadicNoReturn.RLock() + calls = mock.calls.VariadicNoReturn + mock.lockVariadicNoReturn.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go new file mode 100644 index 00000000..9ad07c7d --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go @@ -0,0 +1,76 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that VariadicReturnFunc does implement test.VariadicReturnFunc. +// If this is not the case, regenerate this file with moq. +var _ test.VariadicReturnFunc = &VariadicReturnFunc{} + +// VariadicReturnFunc is a mock implementation of test.VariadicReturnFunc. +// +// func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { +// +// // make and configure a mocked test.VariadicReturnFunc +// mockedVariadicReturnFunc := &VariadicReturnFunc{ +// SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { +// panic("mock out the SampleMethod method") +// }, +// } +// +// // use mockedVariadicReturnFunc in code that requires test.VariadicReturnFunc +// // and then make assertions. +// +// } +type VariadicReturnFunc struct { + // SampleMethodFunc mocks the SampleMethod method. + SampleMethodFunc func(str string) func(str string, arr []int, a ...interface{}) + + // calls tracks calls to the methods. + calls struct { + // SampleMethod holds details about calls to the SampleMethod method. + SampleMethod []struct { + // Str is the str argument value. + Str string + } + } + lockSampleMethod sync.RWMutex +} + +// SampleMethod calls SampleMethodFunc. +func (mock *VariadicReturnFunc) SampleMethod(str string) func(str string, arr []int, a ...interface{}) { + if mock.SampleMethodFunc == nil { + panic("VariadicReturnFunc.SampleMethodFunc: method is nil but VariadicReturnFunc.SampleMethod was just called") + } + callInfo := struct { + Str string + }{ + Str: str, + } + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = append(mock.calls.SampleMethod, callInfo) + mock.lockSampleMethod.Unlock() + return mock.SampleMethodFunc(str) +} + +// SampleMethodCalls gets all the calls that were made to SampleMethod. +// Check the length with: +// +// len(mockedVariadicReturnFunc.SampleMethodCalls()) +func (mock *VariadicReturnFunc) SampleMethodCalls() []struct { + Str string +} { + var calls []struct { + Str string + } + mock.lockSampleMethod.RLock() + calls = mock.calls.SampleMethod + mock.lockSampleMethod.RUnlock() + return calls +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go new file mode 100644 index 00000000..ebd461d1 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go @@ -0,0 +1,67 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package testfoo + +import ( + "sync" +) + +// Ensure, that requester_unexported does implement test.requester_unexported. +// If this is not the case, regenerate this file with moq. +var _ test.requester_unexported = &requester_unexported{} + +// requester_unexported is a mock implementation of test.requester_unexported. +// +// func TestSomethingThatUsesrequester_unexported(t *testing.T) { +// +// // make and configure a mocked test.requester_unexported +// mockedrequester_unexported := &requester_unexported{ +// GetFunc: func() { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedrequester_unexported in code that requires test.requester_unexported +// // and then make assertions. +// +// } +type requester_unexported struct { + // GetFunc mocks the Get method. + GetFunc func() + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *requester_unexported) Get() { + if mock.GetFunc == nil { + panic("requester_unexported.GetFunc: method is nil but requester_unexported.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedrequester_unexported.GetCalls()) +func (mock *requester_unexported) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} From d25b5da8101e65b4fc820bdf08b38f9b8aeb2794 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:48:03 -0600 Subject: [PATCH 32/50] fix config --- .mockery-moq.yaml | 1 - .mockery.yaml | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 97588b92..a304366c 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -10,4 +10,3 @@ packages: all: True style: moq outpkg: testfoo - \ No newline at end of file diff --git a/.mockery.yaml b/.mockery.yaml index 0fdc361d..025d9eef 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -40,12 +40,6 @@ packages: config: with-expecter: True unroll-variadic: False - RequesterReturnElided: - configs: - - mockname: RequesterReturnElided - style: mockery - - mockname: RequesterReturnElidedMoq - style: moq github.com/vektra/mockery/v2/pkg/fixtures/recursive_generation: config: recursive: True @@ -63,4 +57,4 @@ packages: outpkg: "{{.PackageName}}" filename: "mock_{{.InterfaceName}}_test.go" inpackage: True - keeptree: False \ No newline at end of file + keeptree: False From 63653e00984ac6657399df0ff6710acb6814dd5d Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Mon, 12 Feb 2024 18:48:26 -0600 Subject: [PATCH 33/50] fix taskfile --- Taskfile.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index 1d8dfa19..cc4a2b12 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -23,7 +23,6 @@ tasks: cmds: - find . -name '*_mock.go' | xargs rm - rm -rf mocks/ - - rm -rf moqs/ mocks.generate: desc: generate mockery mocks From a0f012b2d277313401351162f503e1f82ad86628 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 12:23:22 -0600 Subject: [PATCH 34/50] Split out warn logs to logging package Add warning when using `moq` style --- .mockery-moq.yaml | 3 +- cmd/mockery.go | 25 +-- .../pkg/fixtures/RequesterReturnElidedMoq.go | 120 ------------ .../v2/pkg/fixtures/RequesterGenerics.go | 179 ------------------ .../v2/pkg/fixtures/UnsafeInterface.go | 76 -------- .../v2/pkg/fixtures/requester_unexported.go | 67 ------- pkg/logging/logging.go | 18 ++ pkg/outputter.go | 2 + 8 files changed, 23 insertions(+), 467 deletions(-) delete mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index a304366c..4d309a3b 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -7,6 +7,7 @@ dir: "mocks/moq/{{.PackagePath}}" packages: github.com/vektra/mockery/v2/pkg/fixtures: config: - all: True + include-regex: '.*' + exclude-regex: 'RequesterGenerics|UnsafeInterface|requester_unexported' style: moq outpkg: testfoo diff --git a/cmd/mockery.go b/cmd/mockery.go index ef72b105..ae90e8c4 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -12,7 +12,6 @@ import ( "github.com/chigopher/pathlib" "github.com/mitchellh/go-homedir" - "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -305,7 +304,7 @@ func (r *RootApp) Run() error { log.Fatal().Msgf("Use --name to specify the name of the interface or --all for all interfaces found") } - warnDeprecated( + logging.WarnDeprecated( ctx, "use of the packages config will be the only way to generate mocks in v3. Please migrate your config to use the packages feature.", map[string]any{ @@ -397,25 +396,3 @@ func (r *RootApp) Run() error { return nil } - -func warn(ctx context.Context, prefix string, message string, fields map[string]any) { - log := zerolog.Ctx(ctx) - event := log.Warn() - if fields != nil { - event = event.Fields(fields) - } - event.Msgf("%s: %s", prefix, message) -} - -func info(ctx context.Context, prefix string, message string, fields map[string]any) { - log := zerolog.Ctx(ctx) - event := log.Info() - if fields != nil { - event = event.Fields(fields) - } - event.Msgf("%s: %s", prefix, message) -} - -func warnDeprecated(ctx context.Context, message string, fields map[string]any) { - warn(ctx, "DEPRECATION", message, fields) -} diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go deleted file mode 100644 index 7551d6a8..00000000 --- a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElidedMoq.go +++ /dev/null @@ -1,120 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package mocks - -import ( - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" -) - -// Ensure, that RequesterReturnElidedMoq does implement test.RequesterReturnElided. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterReturnElided = &RequesterReturnElidedMoq{} - -// RequesterReturnElidedMoq is a mock implementation of test.RequesterReturnElided. -// -// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { -// -// // make and configure a mocked test.RequesterReturnElided -// mockedRequesterReturnElided := &RequesterReturnElidedMoq{ -// GetFunc: func(path string) (int, int, int, error) { -// panic("mock out the Get method") -// }, -// PutFunc: func(path string) (int, error) { -// panic("mock out the Put method") -// }, -// } -// -// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided -// // and then make assertions. -// -// } -type RequesterReturnElidedMoq struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (int, int, int, error) - - // PutFunc mocks the Put method. - PutFunc func(path string) (int, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - // Put holds details about calls to the Put method. - Put []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex - lockPut sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterReturnElidedMoq) Get(path string) (int, int, int, error) { - if mock.GetFunc == nil { - panic("RequesterReturnElidedMoq.GetFunc: method is nil but RequesterReturnElided.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterReturnElided.GetCalls()) -func (mock *RequesterReturnElidedMoq) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// Put calls PutFunc. -func (mock *RequesterReturnElidedMoq) Put(path string) (int, error) { - if mock.PutFunc == nil { - panic("RequesterReturnElidedMoq.PutFunc: method is nil but RequesterReturnElided.Put was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockPut.Lock() - mock.calls.Put = append(mock.calls.Put, callInfo) - mock.lockPut.Unlock() - return mock.PutFunc(path) -} - -// PutCalls gets all the calls that were made to Put. -// Check the length with: -// -// len(mockedRequesterReturnElided.PutCalls()) -func (mock *RequesterReturnElidedMoq) PutCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockPut.RLock() - calls = mock.calls.Put - mock.lockPut.RUnlock() - return calls -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go deleted file mode 100644 index e27ec417..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterGenerics.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package testfoo - -import ( - "io" - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" - "github.com/vektra/mockery/v2/pkg/fixtures/constraints" -) - -// Ensure, that RequesterGenerics does implement test.RequesterGenerics. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int] = &RequesterGenerics[any, comparable, int, test.GetInt, io.Writer, test.GetGeneric[TSigned], int, int]{} - -// RequesterGenerics is a mock implementation of test.RequesterGenerics. -// -// func TestSomethingThatUsesRequesterGenerics(t *testing.T) { -// -// // make and configure a mocked test.RequesterGenerics -// mockedRequesterGenerics := &RequesterGenerics{ -// GenericAnonymousStructsFunc: func(val struct{Type1 TExternalIntf}) struct{Type2 test.GenericType[string, test.EmbeddedGet[int]]} { -// panic("mock out the GenericAnonymousStructs method") -// }, -// GenericArgumentsFunc: func(v1 TAny, v2 TComparable) (TSigned, TIntf) { -// panic("mock out the GenericArguments method") -// }, -// GenericStructsFunc: func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { -// panic("mock out the GenericStructs method") -// }, -// } -// -// // use mockedRequesterGenerics in code that requires test.RequesterGenerics -// // and then make assertions. -// -// } -type RequesterGenerics[TAny any, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { - ~int | GenericType[int, GetInt] - comparable -}] struct { - // GenericAnonymousStructsFunc mocks the GenericAnonymousStructs method. - GenericAnonymousStructsFunc func(val struct{ Type1 TExternalIntf }) struct { - Type2 test.GenericType[string, test.EmbeddedGet[int]] - } - - // GenericArgumentsFunc mocks the GenericArguments method. - GenericArgumentsFunc func(v1 TAny, v2 TComparable) (TSigned, TIntf) - - // GenericStructsFunc mocks the GenericStructs method. - GenericStructsFunc func(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] - - // calls tracks calls to the methods. - calls struct { - // GenericAnonymousStructs holds details about calls to the GenericAnonymousStructs method. - GenericAnonymousStructs []struct { - // Val is the val argument value. - Val struct{ Type1 TExternalIntf } - } - // GenericArguments holds details about calls to the GenericArguments method. - GenericArguments []struct { - // V1 is the v1 argument value. - V1 TAny - // V2 is the v2 argument value. - V2 TComparable - } - // GenericStructs holds details about calls to the GenericStructs method. - GenericStructs []struct { - // GenericType is the genericType argument value. - GenericType test.GenericType[TAny, TIntf] - } - } - lockGenericAnonymousStructs sync.RWMutex - lockGenericArguments sync.RWMutex - lockGenericStructs sync.RWMutex -} - -// GenericAnonymousStructs calls GenericAnonymousStructsFunc. -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructs(val struct{ Type1 TExternalIntf }) struct { - Type2 test.GenericType[string, test.EmbeddedGet[int]] -} { - if mock.GenericAnonymousStructsFunc == nil { - panic("RequesterGenerics.GenericAnonymousStructsFunc: method is nil but RequesterGenerics.GenericAnonymousStructs was just called") - } - callInfo := struct { - Val struct{ Type1 TExternalIntf } - }{ - Val: val, - } - mock.lockGenericAnonymousStructs.Lock() - mock.calls.GenericAnonymousStructs = append(mock.calls.GenericAnonymousStructs, callInfo) - mock.lockGenericAnonymousStructs.Unlock() - return mock.GenericAnonymousStructsFunc(val) -} - -// GenericAnonymousStructsCalls gets all the calls that were made to GenericAnonymousStructs. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericAnonymousStructsCalls()) -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructsCalls() []struct { - Val struct{ Type1 TExternalIntf } -} { - var calls []struct { - Val struct{ Type1 TExternalIntf } - } - mock.lockGenericAnonymousStructs.RLock() - calls = mock.calls.GenericAnonymousStructs - mock.lockGenericAnonymousStructs.RUnlock() - return calls -} - -// GenericArguments calls GenericArgumentsFunc. -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArguments(v1 TAny, v2 TComparable) (TSigned, TIntf) { - if mock.GenericArgumentsFunc == nil { - panic("RequesterGenerics.GenericArgumentsFunc: method is nil but RequesterGenerics.GenericArguments was just called") - } - callInfo := struct { - V1 TAny - V2 TComparable - }{ - V1: v1, - V2: v2, - } - mock.lockGenericArguments.Lock() - mock.calls.GenericArguments = append(mock.calls.GenericArguments, callInfo) - mock.lockGenericArguments.Unlock() - return mock.GenericArgumentsFunc(v1, v2) -} - -// GenericArgumentsCalls gets all the calls that were made to GenericArguments. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericArgumentsCalls()) -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArgumentsCalls() []struct { - V1 TAny - V2 TComparable -} { - var calls []struct { - V1 TAny - V2 TComparable - } - mock.lockGenericArguments.RLock() - calls = mock.calls.GenericArguments - mock.lockGenericArguments.RUnlock() - return calls -} - -// GenericStructs calls GenericStructsFunc. -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructs(genericType test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { - if mock.GenericStructsFunc == nil { - panic("RequesterGenerics.GenericStructsFunc: method is nil but RequesterGenerics.GenericStructs was just called") - } - callInfo := struct { - GenericType test.GenericType[TAny, TIntf] - }{ - GenericType: genericType, - } - mock.lockGenericStructs.Lock() - mock.calls.GenericStructs = append(mock.calls.GenericStructs, callInfo) - mock.lockGenericStructs.Unlock() - return mock.GenericStructsFunc(genericType) -} - -// GenericStructsCalls gets all the calls that were made to GenericStructs. -// Check the length with: -// -// len(mockedRequesterGenerics.GenericStructsCalls()) -func (mock *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructsCalls() []struct { - GenericType test.GenericType[TAny, TIntf] -} { - var calls []struct { - GenericType test.GenericType[TAny, TIntf] - } - mock.lockGenericStructs.RLock() - calls = mock.calls.GenericStructs - mock.lockGenericStructs.RUnlock() - return calls -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go deleted file mode 100644 index d58735c9..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UnsafeInterface.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package testfoo - -import ( - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" -) - -// Ensure, that UnsafeInterface does implement test.UnsafeInterface. -// If this is not the case, regenerate this file with moq. -var _ test.UnsafeInterface = &UnsafeInterface{} - -// UnsafeInterface is a mock implementation of test.UnsafeInterface. -// -// func TestSomethingThatUsesUnsafeInterface(t *testing.T) { -// -// // make and configure a mocked test.UnsafeInterface -// mockedUnsafeInterface := &UnsafeInterface{ -// DoFunc: func(ptr *Pointer) { -// panic("mock out the Do method") -// }, -// } -// -// // use mockedUnsafeInterface in code that requires test.UnsafeInterface -// // and then make assertions. -// -// } -type UnsafeInterface struct { - // DoFunc mocks the Do method. - DoFunc func(ptr *Pointer) - - // calls tracks calls to the methods. - calls struct { - // Do holds details about calls to the Do method. - Do []struct { - // Ptr is the ptr argument value. - Ptr *Pointer - } - } - lockDo sync.RWMutex -} - -// Do calls DoFunc. -func (mock *UnsafeInterface) Do(ptr *Pointer) { - if mock.DoFunc == nil { - panic("UnsafeInterface.DoFunc: method is nil but UnsafeInterface.Do was just called") - } - callInfo := struct { - Ptr *Pointer - }{ - Ptr: ptr, - } - mock.lockDo.Lock() - mock.calls.Do = append(mock.calls.Do, callInfo) - mock.lockDo.Unlock() - mock.DoFunc(ptr) -} - -// DoCalls gets all the calls that were made to Do. -// Check the length with: -// -// len(mockedUnsafeInterface.DoCalls()) -func (mock *UnsafeInterface) DoCalls() []struct { - Ptr *Pointer -} { - var calls []struct { - Ptr *Pointer - } - mock.lockDo.RLock() - calls = mock.calls.Do - mock.lockDo.RUnlock() - return calls -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go deleted file mode 100644 index ebd461d1..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_unexported.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package testfoo - -import ( - "sync" -) - -// Ensure, that requester_unexported does implement test.requester_unexported. -// If this is not the case, regenerate this file with moq. -var _ test.requester_unexported = &requester_unexported{} - -// requester_unexported is a mock implementation of test.requester_unexported. -// -// func TestSomethingThatUsesrequester_unexported(t *testing.T) { -// -// // make and configure a mocked test.requester_unexported -// mockedrequester_unexported := &requester_unexported{ -// GetFunc: func() { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedrequester_unexported in code that requires test.requester_unexported -// // and then make assertions. -// -// } -type requester_unexported struct { - // GetFunc mocks the Get method. - GetFunc func() - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *requester_unexported) Get() { - if mock.GetFunc == nil { - panic("requester_unexported.GetFunc: method is nil but requester_unexported.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedrequester_unexported.GetCalls()) -func (mock *requester_unexported) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index b6694ef3..f79f36e1 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -1,6 +1,7 @@ package logging import ( + "context" "errors" "fmt" "os" @@ -86,3 +87,20 @@ func GetLogger(levelStr string) (zerolog.Logger, error) { return log, nil } + +func Warn(ctx context.Context, prefix string, message string, fields map[string]any) { + log := zerolog.Ctx(ctx) + event := log.Warn() + if fields != nil { + event = event.Fields(fields) + } + event.Msgf("%s: %s", prefix, message) +} + +func WarnDeprecated(ctx context.Context, message string, fields map[string]any) { + Warn(ctx, "DEPRECATION", message, fields) +} + +func WarnAlpha(ctx context.Context, message string, fields map[string]any) { + Warn(ctx, "ALPHA FEATURE", message, fields) +} diff --git a/pkg/outputter.go b/pkg/outputter.go index 313e09a4..d92eb2b0 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -322,6 +322,7 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { for _, interfaceConfig := range interfaceConfigs { interfaceConfig.LogUnsupportedPackagesConfig(ctx) ifaceLog := log.With().Str("style", interfaceConfig.Style).Logger() + ifaceCtx := ifaceLog.WithContext(ctx) if err := parseConfigTemplates(ctx, interfaceConfig, iface); err != nil { return fmt.Errorf("failed to parse config template: %w", err) @@ -331,6 +332,7 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { o.generateMockery(ctx, iface, interfaceConfig) continue } + logging.WarnAlpha(ifaceCtx, "usage mock styles other than mockery is currently in an alpha state.", nil) ifaceLog.Debug().Msg("generating templated mock") config := generator.TemplateGeneratorConfig{ From 19b9718f7b75663a9c1cc2a5d98223ed6c183864 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 12:57:50 -0600 Subject: [PATCH 35/50] Add template-map config param. Factor out TypeInstantiation into separate function. --- .mockery-moq.yaml | 6 +- .../vektra/mockery/v2/pkg/fixtures/A.go | 26 ++++--- .../mockery/v2/pkg/fixtures/AsyncProducer.go | 50 ++++++++++--- .../vektra/mockery/v2/pkg/fixtures/Blank.go | 28 +++++--- .../mockery/v2/pkg/fixtures/ConsulLock.go | 39 +++++++--- .../mockery/v2/pkg/fixtures/EmbeddedGet.go | 27 ++++--- .../vektra/mockery/v2/pkg/fixtures/Example.go | 38 +++++++--- .../mockery/v2/pkg/fixtures/Expecter.go | 72 ++++++++++++++++--- .../vektra/mockery/v2/pkg/fixtures/Fooer.go | 50 ++++++++++--- .../v2/pkg/fixtures/FuncArgsCollision.go | 28 +++++--- .../mockery/v2/pkg/fixtures/GetGeneric.go | 27 ++++--- .../vektra/mockery/v2/pkg/fixtures/GetInt.go | 28 +++++--- .../fixtures/HasConflictingNestedImports.go | 38 +++++++--- .../v2/pkg/fixtures/ImportsSameAsPackage.go | 48 ++++++++++--- .../mockery/v2/pkg/fixtures/KeyManager.go | 26 ++++--- .../vektra/mockery/v2/pkg/fixtures/MapFunc.go | 28 +++++--- .../mockery/v2/pkg/fixtures/MapToInterface.go | 28 +++++--- .../mockery/v2/pkg/fixtures/MyReader.go | 28 +++++--- .../v2/pkg/fixtures/PanicOnNoReturnValue.go | 28 +++++--- .../mockery/v2/pkg/fixtures/Requester.go | 28 +++++--- .../mockery/v2/pkg/fixtures/Requester2.go | 28 +++++--- .../mockery/v2/pkg/fixtures/Requester3.go | 28 +++++--- .../mockery/v2/pkg/fixtures/Requester4.go | 28 +++++--- .../pkg/fixtures/RequesterArgSameAsImport.go | 28 +++++--- .../fixtures/RequesterArgSameAsNamedImport.go | 28 +++++--- .../v2/pkg/fixtures/RequesterArgSameAsPkg.go | 28 +++++--- .../mockery/v2/pkg/fixtures/RequesterArray.go | 28 +++++--- .../v2/pkg/fixtures/RequesterElided.go | 28 +++++--- .../mockery/v2/pkg/fixtures/RequesterIface.go | 28 +++++--- .../mockery/v2/pkg/fixtures/RequesterNS.go | 28 +++++--- .../mockery/v2/pkg/fixtures/RequesterPtr.go | 28 +++++--- .../v2/pkg/fixtures/RequesterReturnElided.go | 39 +++++++--- .../mockery/v2/pkg/fixtures/RequesterSlice.go | 28 +++++--- .../v2/pkg/fixtures/RequesterVariadic.go | 61 +++++++++++++--- .../vektra/mockery/v2/pkg/fixtures/Sibling.go | 28 +++++--- .../mockery/v2/pkg/fixtures/StructWithTag.go | 28 +++++--- .../v2/pkg/fixtures/UsesOtherPkgIface.go | 26 ++++--- .../mockery/v2/pkg/fixtures/Variadic.go | 28 +++++--- .../pkg/fixtures/VariadicNoReturnInterface.go | 28 +++++--- .../v2/pkg/fixtures/VariadicReturnFunc.go | 28 +++++--- pkg/config/config.go | 19 ++--- pkg/generator/template_generator.go | 9 ++- pkg/template/moq.templ | 32 +++------ pkg/template/template.go | 28 ++++++-- pkg/template/template_data.go | 1 + 45 files changed, 941 insertions(+), 421 deletions(-) diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 4d309a3b..4ddeb002 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -10,4 +10,8 @@ packages: include-regex: '.*' exclude-regex: 'RequesterGenerics|UnsafeInterface|requester_unexported' style: moq - outpkg: testfoo + outpkg: test + template-map: + with-resets: true + skip-ensure: true + stub-impl: false diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go index 99e21496..279586d1 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go @@ -1,7 +1,7 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" @@ -9,22 +9,18 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that A does implement test.A. -// If this is not the case, regenerate this file with moq. -var _ test.A = &A{} - -// A is a mock implementation of test.A. +// A is a mock implementation of A. // // func TestSomethingThatUsesA(t *testing.T) { // -// // make and configure a mocked test.A +// // make and configure a mocked A // mockedA := &A{ // CallFunc: func() (test.B, error) { // panic("mock out the Call method") // }, // } // -// // use mockedA in code that requires test.A +// // use mockedA in code that requires A // // and then make assertions. // // } @@ -67,3 +63,17 @@ func (mock *A) CallCalls() []struct { mock.lockCall.RUnlock() return calls } + +// ResetCallCalls reset all the calls that were made to Call. +func (mock *A) ResetCallCalls() { + mock.lockCall.Lock() + mock.calls.Call = nil + mock.lockCall.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *A) ResetCalls() { + mock.lockCall.Lock() + mock.calls.Call = nil + mock.lockCall.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go index cc23dd22..c86ec9e3 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go @@ -1,23 +1,17 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that AsyncProducer does implement test.AsyncProducer. -// If this is not the case, regenerate this file with moq. -var _ test.AsyncProducer = &AsyncProducer{} - -// AsyncProducer is a mock implementation of test.AsyncProducer. +// AsyncProducer is a mock implementation of AsyncProducer. // // func TestSomethingThatUsesAsyncProducer(t *testing.T) { // -// // make and configure a mocked test.AsyncProducer +// // make and configure a mocked AsyncProducer // mockedAsyncProducer := &AsyncProducer{ // InputFunc: func() chan<- bool { // panic("mock out the Input method") @@ -30,7 +24,7 @@ var _ test.AsyncProducer = &AsyncProducer{} // }, // } // -// // use mockedAsyncProducer in code that requires test.AsyncProducer +// // use mockedAsyncProducer in code that requires AsyncProducer // // and then make assertions. // // } @@ -88,6 +82,13 @@ func (mock *AsyncProducer) InputCalls() []struct { return calls } +// ResetInputCalls reset all the calls that were made to Input. +func (mock *AsyncProducer) ResetInputCalls() { + mock.lockInput.Lock() + mock.calls.Input = nil + mock.lockInput.Unlock() +} + // Output calls OutputFunc. func (mock *AsyncProducer) Output() <-chan bool { if mock.OutputFunc == nil { @@ -115,6 +116,13 @@ func (mock *AsyncProducer) OutputCalls() []struct { return calls } +// ResetOutputCalls reset all the calls that were made to Output. +func (mock *AsyncProducer) ResetOutputCalls() { + mock.lockOutput.Lock() + mock.calls.Output = nil + mock.lockOutput.Unlock() +} + // Whatever calls WhateverFunc. func (mock *AsyncProducer) Whatever() chan bool { if mock.WhateverFunc == nil { @@ -141,3 +149,25 @@ func (mock *AsyncProducer) WhateverCalls() []struct { mock.lockWhatever.RUnlock() return calls } + +// ResetWhateverCalls reset all the calls that were made to Whatever. +func (mock *AsyncProducer) ResetWhateverCalls() { + mock.lockWhatever.Lock() + mock.calls.Whatever = nil + mock.lockWhatever.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *AsyncProducer) ResetCalls() { + mock.lockInput.Lock() + mock.calls.Input = nil + mock.lockInput.Unlock() + + mock.lockOutput.Lock() + mock.calls.Output = nil + mock.lockOutput.Unlock() + + mock.lockWhatever.Lock() + mock.calls.Whatever = nil + mock.lockWhatever.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go index 1bc7f8d6..dae12d57 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Blank does implement test.Blank. -// If this is not the case, regenerate this file with moq. -var _ test.Blank = &Blank{} - -// Blank is a mock implementation of test.Blank. +// Blank is a mock implementation of Blank. // // func TestSomethingThatUsesBlank(t *testing.T) { // -// // make and configure a mocked test.Blank +// // make and configure a mocked Blank // mockedBlank := &Blank{ // CreateFunc: func(x interface{}) error { // panic("mock out the Create method") // }, // } // -// // use mockedBlank in code that requires test.Blank +// // use mockedBlank in code that requires Blank // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *Blank) CreateCalls() []struct { mock.lockCreate.RUnlock() return calls } + +// ResetCreateCalls reset all the calls that were made to Create. +func (mock *Blank) ResetCreateCalls() { + mock.lockCreate.Lock() + mock.calls.Create = nil + mock.lockCreate.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Blank) ResetCalls() { + mock.lockCreate.Lock() + mock.calls.Create = nil + mock.lockCreate.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go index 27b0c869..e41959a4 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go @@ -1,23 +1,17 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that ConsulLock does implement test.ConsulLock. -// If this is not the case, regenerate this file with moq. -var _ test.ConsulLock = &ConsulLock{} - -// ConsulLock is a mock implementation of test.ConsulLock. +// ConsulLock is a mock implementation of ConsulLock. // // func TestSomethingThatUsesConsulLock(t *testing.T) { // -// // make and configure a mocked test.ConsulLock +// // make and configure a mocked ConsulLock // mockedConsulLock := &ConsulLock{ // LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { // panic("mock out the Lock method") @@ -27,7 +21,7 @@ var _ test.ConsulLock = &ConsulLock{} // }, // } // -// // use mockedConsulLock in code that requires test.ConsulLock +// // use mockedConsulLock in code that requires ConsulLock // // and then make assertions. // // } @@ -85,6 +79,13 @@ func (mock *ConsulLock) LockCalls() []struct { return calls } +// ResetLockCalls reset all the calls that were made to Lock. +func (mock *ConsulLock) ResetLockCalls() { + mock.lockLock.Lock() + mock.calls.Lock = nil + mock.lockLock.Unlock() +} + // Unlock calls UnlockFunc. func (mock *ConsulLock) Unlock() error { if mock.UnlockFunc == nil { @@ -111,3 +112,21 @@ func (mock *ConsulLock) UnlockCalls() []struct { mock.lockUnlock.RUnlock() return calls } + +// ResetUnlockCalls reset all the calls that were made to Unlock. +func (mock *ConsulLock) ResetUnlockCalls() { + mock.lockUnlock.Lock() + mock.calls.Unlock = nil + mock.lockUnlock.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ConsulLock) ResetCalls() { + mock.lockLock.Lock() + mock.calls.Lock = nil + mock.lockLock.Unlock() + + mock.lockUnlock.Lock() + mock.calls.Unlock = nil + mock.lockUnlock.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go index 7d199e3a..4e92eb91 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go @@ -1,31 +1,26 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - test "github.com/vektra/mockery/v2/pkg/fixtures" "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// Ensure, that EmbeddedGet does implement test.EmbeddedGet. -// If this is not the case, regenerate this file with moq. -var _ test.EmbeddedGet[int] = &EmbeddedGet[int]{} - -// EmbeddedGet is a mock implementation of test.EmbeddedGet. +// EmbeddedGet is a mock implementation of EmbeddedGet. // // func TestSomethingThatUsesEmbeddedGet(t *testing.T) { // -// // make and configure a mocked test.EmbeddedGet +// // make and configure a mocked EmbeddedGet // mockedEmbeddedGet := &EmbeddedGet{ // GetFunc: func() T { // panic("mock out the Get method") // }, // } // -// // use mockedEmbeddedGet in code that requires test.EmbeddedGet +// // use mockedEmbeddedGet in code that requires EmbeddedGet // // and then make assertions. // // } @@ -68,3 +63,17 @@ func (mock *EmbeddedGet[T]) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *EmbeddedGet[T]) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *EmbeddedGet[T]) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go index 96001a47..c2e8c675 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go @@ -1,25 +1,20 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "net/http" "sync" - test "github.com/vektra/mockery/v2/pkg/fixtures" my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// Ensure, that Example does implement test.Example. -// If this is not the case, regenerate this file with moq. -var _ test.Example = &Example{} - -// Example is a mock implementation of test.Example. +// Example is a mock implementation of Example. // // func TestSomethingThatUsesExample(t *testing.T) { // -// // make and configure a mocked test.Example +// // make and configure a mocked Example // mockedExample := &Example{ // AFunc: func() http.Flusher { // panic("mock out the A method") @@ -29,7 +24,7 @@ var _ test.Example = &Example{} // }, // } // -// // use mockedExample in code that requires test.Example +// // use mockedExample in code that requires Example // // and then make assertions. // // } @@ -82,6 +77,13 @@ func (mock *Example) ACalls() []struct { return calls } +// ResetACalls reset all the calls that were made to A. +func (mock *Example) ResetACalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() +} + // B calls BFunc. func (mock *Example) B(fixtureshttp string) my_http.MyStruct { if mock.BFunc == nil { @@ -113,3 +115,21 @@ func (mock *Example) BCalls() []struct { mock.lockB.RUnlock() return calls } + +// ResetBCalls reset all the calls that were made to B. +func (mock *Example) ResetBCalls() { + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Example) ResetCalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() + + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go index 8b2abb10..d173753d 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go @@ -1,23 +1,17 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Expecter does implement test.Expecter. -// If this is not the case, regenerate this file with moq. -var _ test.Expecter = &Expecter{} - -// Expecter is a mock implementation of test.Expecter. +// Expecter is a mock implementation of Expecter. // // func TestSomethingThatUsesExpecter(t *testing.T) { // -// // make and configure a mocked test.Expecter +// // make and configure a mocked Expecter // mockedExpecter := &Expecter{ // ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { // panic("mock out the ManyArgsReturns method") @@ -36,7 +30,7 @@ var _ test.Expecter = &Expecter{} // }, // } // -// // use mockedExpecter in code that requires test.Expecter +// // use mockedExpecter in code that requires Expecter // // and then make assertions. // // } @@ -131,6 +125,13 @@ func (mock *Expecter) ManyArgsReturnsCalls() []struct { return calls } +// ResetManyArgsReturnsCalls reset all the calls that were made to ManyArgsReturns. +func (mock *Expecter) ResetManyArgsReturnsCalls() { + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = nil + mock.lockManyArgsReturns.Unlock() +} + // NoArg calls NoArgFunc. func (mock *Expecter) NoArg() string { if mock.NoArgFunc == nil { @@ -158,6 +159,13 @@ func (mock *Expecter) NoArgCalls() []struct { return calls } +// ResetNoArgCalls reset all the calls that were made to NoArg. +func (mock *Expecter) ResetNoArgCalls() { + mock.lockNoArg.Lock() + mock.calls.NoArg = nil + mock.lockNoArg.Unlock() +} + // NoReturn calls NoReturnFunc. func (mock *Expecter) NoReturn(str string) { if mock.NoReturnFunc == nil { @@ -190,6 +198,13 @@ func (mock *Expecter) NoReturnCalls() []struct { return calls } +// ResetNoReturnCalls reset all the calls that were made to NoReturn. +func (mock *Expecter) ResetNoReturnCalls() { + mock.lockNoReturn.Lock() + mock.calls.NoReturn = nil + mock.lockNoReturn.Unlock() +} + // Variadic calls VariadicFunc. func (mock *Expecter) Variadic(ints ...int) error { if mock.VariadicFunc == nil { @@ -222,6 +237,13 @@ func (mock *Expecter) VariadicCalls() []struct { return calls } +// ResetVariadicCalls reset all the calls that were made to Variadic. +func (mock *Expecter) ResetVariadicCalls() { + mock.lockVariadic.Lock() + mock.calls.Variadic = nil + mock.lockVariadic.Unlock() +} + // VariadicMany calls VariadicManyFunc. func (mock *Expecter) VariadicMany(i int, a string, intfs ...interface{}) error { if mock.VariadicManyFunc == nil { @@ -261,3 +283,33 @@ func (mock *Expecter) VariadicManyCalls() []struct { mock.lockVariadicMany.RUnlock() return calls } + +// ResetVariadicManyCalls reset all the calls that were made to VariadicMany. +func (mock *Expecter) ResetVariadicManyCalls() { + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = nil + mock.lockVariadicMany.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Expecter) ResetCalls() { + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = nil + mock.lockManyArgsReturns.Unlock() + + mock.lockNoArg.Lock() + mock.calls.NoArg = nil + mock.lockNoArg.Unlock() + + mock.lockNoReturn.Lock() + mock.calls.NoReturn = nil + mock.lockNoReturn.Unlock() + + mock.lockVariadic.Lock() + mock.calls.Variadic = nil + mock.lockVariadic.Unlock() + + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = nil + mock.lockVariadicMany.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go index 09eb6803..fd07804b 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go @@ -1,23 +1,17 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Fooer does implement test.Fooer. -// If this is not the case, regenerate this file with moq. -var _ test.Fooer = &Fooer{} - -// Fooer is a mock implementation of test.Fooer. +// Fooer is a mock implementation of Fooer. // // func TestSomethingThatUsesFooer(t *testing.T) { // -// // make and configure a mocked test.Fooer +// // make and configure a mocked Fooer // mockedFooer := &Fooer{ // BarFunc: func(f func([]int)) { // panic("mock out the Bar method") @@ -30,7 +24,7 @@ var _ test.Fooer = &Fooer{} // }, // } // -// // use mockedFooer in code that requires test.Fooer +// // use mockedFooer in code that requires Fooer // // and then make assertions. // // } @@ -99,6 +93,13 @@ func (mock *Fooer) BarCalls() []struct { return calls } +// ResetBarCalls reset all the calls that were made to Bar. +func (mock *Fooer) ResetBarCalls() { + mock.lockBar.Lock() + mock.calls.Bar = nil + mock.lockBar.Unlock() +} + // Baz calls BazFunc. func (mock *Fooer) Baz(path string) func(x string) string { if mock.BazFunc == nil { @@ -131,6 +132,13 @@ func (mock *Fooer) BazCalls() []struct { return calls } +// ResetBazCalls reset all the calls that were made to Baz. +func (mock *Fooer) ResetBazCalls() { + mock.lockBaz.Lock() + mock.calls.Baz = nil + mock.lockBaz.Unlock() +} + // Foo calls FooFunc. func (mock *Fooer) Foo(f func(x string) string) error { if mock.FooFunc == nil { @@ -162,3 +170,25 @@ func (mock *Fooer) FooCalls() []struct { mock.lockFoo.RUnlock() return calls } + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *Fooer) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Fooer) ResetCalls() { + mock.lockBar.Lock() + mock.calls.Bar = nil + mock.lockBar.Unlock() + + mock.lockBaz.Lock() + mock.calls.Baz = nil + mock.lockBaz.Unlock() + + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go index 7aa0374e..b6010f76 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that FuncArgsCollision does implement test.FuncArgsCollision. -// If this is not the case, regenerate this file with moq. -var _ test.FuncArgsCollision = &FuncArgsCollision{} - -// FuncArgsCollision is a mock implementation of test.FuncArgsCollision. +// FuncArgsCollision is a mock implementation of FuncArgsCollision. // // func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { // -// // make and configure a mocked test.FuncArgsCollision +// // make and configure a mocked FuncArgsCollision // mockedFuncArgsCollision := &FuncArgsCollision{ // FooFunc: func(ret interface{}) error { // panic("mock out the Foo method") // }, // } // -// // use mockedFuncArgsCollision in code that requires test.FuncArgsCollision +// // use mockedFuncArgsCollision in code that requires FuncArgsCollision // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *FuncArgsCollision) FooCalls() []struct { mock.lockFoo.RUnlock() return calls } + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *FuncArgsCollision) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *FuncArgsCollision) ResetCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go index 9ebffbdc..00330f51 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go @@ -1,31 +1,26 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - test "github.com/vektra/mockery/v2/pkg/fixtures" "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// Ensure, that GetGeneric does implement test.GetGeneric. -// If this is not the case, regenerate this file with moq. -var _ test.GetGeneric[int] = &GetGeneric[int]{} - -// GetGeneric is a mock implementation of test.GetGeneric. +// GetGeneric is a mock implementation of GetGeneric. // // func TestSomethingThatUsesGetGeneric(t *testing.T) { // -// // make and configure a mocked test.GetGeneric +// // make and configure a mocked GetGeneric // mockedGetGeneric := &GetGeneric{ // GetFunc: func() T { // panic("mock out the Get method") // }, // } // -// // use mockedGetGeneric in code that requires test.GetGeneric +// // use mockedGetGeneric in code that requires GetGeneric // // and then make assertions. // // } @@ -68,3 +63,17 @@ func (mock *GetGeneric[T]) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *GetGeneric[T]) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *GetGeneric[T]) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go index 5bc165d4..bfa3335f 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that GetInt does implement test.GetInt. -// If this is not the case, regenerate this file with moq. -var _ test.GetInt = &GetInt{} - -// GetInt is a mock implementation of test.GetInt. +// GetInt is a mock implementation of GetInt. // // func TestSomethingThatUsesGetInt(t *testing.T) { // -// // make and configure a mocked test.GetInt +// // make and configure a mocked GetInt // mockedGetInt := &GetInt{ // GetFunc: func() int { // panic("mock out the Get method") // }, // } // -// // use mockedGetInt in code that requires test.GetInt +// // use mockedGetInt in code that requires GetInt // // and then make assertions. // // } @@ -67,3 +61,17 @@ func (mock *GetInt) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *GetInt) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *GetInt) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go index eb30a280..b6212212 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go @@ -1,25 +1,20 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "net/http" "sync" - test "github.com/vektra/mockery/v2/pkg/fixtures" my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// Ensure, that HasConflictingNestedImports does implement test.HasConflictingNestedImports. -// If this is not the case, regenerate this file with moq. -var _ test.HasConflictingNestedImports = &HasConflictingNestedImports{} - -// HasConflictingNestedImports is a mock implementation of test.HasConflictingNestedImports. +// HasConflictingNestedImports is a mock implementation of HasConflictingNestedImports. // // func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { // -// // make and configure a mocked test.HasConflictingNestedImports +// // make and configure a mocked HasConflictingNestedImports // mockedHasConflictingNestedImports := &HasConflictingNestedImports{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") @@ -29,7 +24,7 @@ var _ test.HasConflictingNestedImports = &HasConflictingNestedImports{} // }, // } // -// // use mockedHasConflictingNestedImports in code that requires test.HasConflictingNestedImports +// // use mockedHasConflictingNestedImports in code that requires HasConflictingNestedImports // // and then make assertions. // // } @@ -87,6 +82,13 @@ func (mock *HasConflictingNestedImports) GetCalls() []struct { return calls } +// ResetGetCalls reset all the calls that were made to Get. +func (mock *HasConflictingNestedImports) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + // Z calls ZFunc. func (mock *HasConflictingNestedImports) Z() my_http.MyStruct { if mock.ZFunc == nil { @@ -113,3 +115,21 @@ func (mock *HasConflictingNestedImports) ZCalls() []struct { mock.lockZ.RUnlock() return calls } + +// ResetZCalls reset all the calls that were made to Z. +func (mock *HasConflictingNestedImports) ResetZCalls() { + mock.lockZ.Lock() + mock.calls.Z = nil + mock.lockZ.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *HasConflictingNestedImports) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockZ.Lock() + mock.calls.Z = nil + mock.lockZ.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go index 423e2bf3..589ae3f7 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go @@ -1,7 +1,7 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" @@ -10,15 +10,11 @@ import ( redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" ) -// Ensure, that ImportsSameAsPackage does implement fixtures.ImportsSameAsPackage. -// If this is not the case, regenerate this file with moq. -var _ fixtures.ImportsSameAsPackage = &ImportsSameAsPackage{} - -// ImportsSameAsPackage is a mock implementation of fixtures.ImportsSameAsPackage. +// ImportsSameAsPackage is a mock implementation of ImportsSameAsPackage. // // func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { // -// // make and configure a mocked fixtures.ImportsSameAsPackage +// // make and configure a mocked ImportsSameAsPackage // mockedImportsSameAsPackage := &ImportsSameAsPackage{ // AFunc: func() redefinedtypeb.B { // panic("mock out the A method") @@ -31,7 +27,7 @@ var _ fixtures.ImportsSameAsPackage = &ImportsSameAsPackage{} // }, // } // -// // use mockedImportsSameAsPackage in code that requires fixtures.ImportsSameAsPackage +// // use mockedImportsSameAsPackage in code that requires ImportsSameAsPackage // // and then make assertions. // // } @@ -91,6 +87,13 @@ func (mock *ImportsSameAsPackage) ACalls() []struct { return calls } +// ResetACalls reset all the calls that were made to A. +func (mock *ImportsSameAsPackage) ResetACalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() +} + // B calls BFunc. func (mock *ImportsSameAsPackage) B() fixtures.KeyManager { if mock.BFunc == nil { @@ -118,6 +121,13 @@ func (mock *ImportsSameAsPackage) BCalls() []struct { return calls } +// ResetBCalls reset all the calls that were made to B. +func (mock *ImportsSameAsPackage) ResetBCalls() { + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} + // C calls CFunc. func (mock *ImportsSameAsPackage) C(c fixtures.C) { if mock.CFunc == nil { @@ -149,3 +159,25 @@ func (mock *ImportsSameAsPackage) CCalls() []struct { mock.lockC.RUnlock() return calls } + +// ResetCCalls reset all the calls that were made to C. +func (mock *ImportsSameAsPackage) ResetCCalls() { + mock.lockC.Lock() + mock.calls.C = nil + mock.lockC.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ImportsSameAsPackage) ResetCalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() + + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() + + mock.lockC.Lock() + mock.calls.C = nil + mock.lockC.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go index 59bc5154..f152a015 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go @@ -1,7 +1,7 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" @@ -9,22 +9,18 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that KeyManager does implement test.KeyManager. -// If this is not the case, regenerate this file with moq. -var _ test.KeyManager = &KeyManager{} - -// KeyManager is a mock implementation of test.KeyManager. +// KeyManager is a mock implementation of KeyManager. // // func TestSomethingThatUsesKeyManager(t *testing.T) { // -// // make and configure a mocked test.KeyManager +// // make and configure a mocked KeyManager // mockedKeyManager := &KeyManager{ // GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { // panic("mock out the GetKey method") // }, // } // -// // use mockedKeyManager in code that requires test.KeyManager +// // use mockedKeyManager in code that requires KeyManager // // and then make assertions. // // } @@ -80,3 +76,17 @@ func (mock *KeyManager) GetKeyCalls() []struct { mock.lockGetKey.RUnlock() return calls } + +// ResetGetKeyCalls reset all the calls that were made to GetKey. +func (mock *KeyManager) ResetGetKeyCalls() { + mock.lockGetKey.Lock() + mock.calls.GetKey = nil + mock.lockGetKey.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *KeyManager) ResetCalls() { + mock.lockGetKey.Lock() + mock.calls.GetKey = nil + mock.lockGetKey.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go index f742b8e0..36c9cc88 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MapFunc does implement test.MapFunc. -// If this is not the case, regenerate this file with moq. -var _ test.MapFunc = &MapFunc{} - -// MapFunc is a mock implementation of test.MapFunc. +// MapFunc is a mock implementation of MapFunc. // // func TestSomethingThatUsesMapFunc(t *testing.T) { // -// // make and configure a mocked test.MapFunc +// // make and configure a mocked MapFunc // mockedMapFunc := &MapFunc{ // GetFunc: func(m map[string]func(string) string) error { // panic("mock out the Get method") // }, // } // -// // use mockedMapFunc in code that requires test.MapFunc +// // use mockedMapFunc in code that requires MapFunc // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *MapFunc) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *MapFunc) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MapFunc) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go index 7cd5a2f1..8edc6b7c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MapToInterface does implement test.MapToInterface. -// If this is not the case, regenerate this file with moq. -var _ test.MapToInterface = &MapToInterface{} - -// MapToInterface is a mock implementation of test.MapToInterface. +// MapToInterface is a mock implementation of MapToInterface. // // func TestSomethingThatUsesMapToInterface(t *testing.T) { // -// // make and configure a mocked test.MapToInterface +// // make and configure a mocked MapToInterface // mockedMapToInterface := &MapToInterface{ // FooFunc: func(arg1 ...map[string]interface{}) { // panic("mock out the Foo method") // }, // } // -// // use mockedMapToInterface in code that requires test.MapToInterface +// // use mockedMapToInterface in code that requires MapToInterface // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *MapToInterface) FooCalls() []struct { mock.lockFoo.RUnlock() return calls } + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *MapToInterface) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MapToInterface) ResetCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go index 9b852377..c6236a74 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MyReader does implement test.MyReader. -// If this is not the case, regenerate this file with moq. -var _ test.MyReader = &MyReader{} - -// MyReader is a mock implementation of test.MyReader. +// MyReader is a mock implementation of MyReader. // // func TestSomethingThatUsesMyReader(t *testing.T) { // -// // make and configure a mocked test.MyReader +// // make and configure a mocked MyReader // mockedMyReader := &MyReader{ // ReadFunc: func(p []byte) (int, error) { // panic("mock out the Read method") // }, // } // -// // use mockedMyReader in code that requires test.MyReader +// // use mockedMyReader in code that requires MyReader // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *MyReader) ReadCalls() []struct { mock.lockRead.RUnlock() return calls } + +// ResetReadCalls reset all the calls that were made to Read. +func (mock *MyReader) ResetReadCalls() { + mock.lockRead.Lock() + mock.calls.Read = nil + mock.lockRead.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MyReader) ResetCalls() { + mock.lockRead.Lock() + mock.calls.Read = nil + mock.lockRead.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go index 51935887..a8f88660 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that PanicOnNoReturnValue does implement test.PanicOnNoReturnValue. -// If this is not the case, regenerate this file with moq. -var _ test.PanicOnNoReturnValue = &PanicOnNoReturnValue{} - -// PanicOnNoReturnValue is a mock implementation of test.PanicOnNoReturnValue. +// PanicOnNoReturnValue is a mock implementation of PanicOnNoReturnValue. // // func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { // -// // make and configure a mocked test.PanicOnNoReturnValue +// // make and configure a mocked PanicOnNoReturnValue // mockedPanicOnNoReturnValue := &PanicOnNoReturnValue{ // DoSomethingFunc: func() string { // panic("mock out the DoSomething method") // }, // } // -// // use mockedPanicOnNoReturnValue in code that requires test.PanicOnNoReturnValue +// // use mockedPanicOnNoReturnValue in code that requires PanicOnNoReturnValue // // and then make assertions. // // } @@ -67,3 +61,17 @@ func (mock *PanicOnNoReturnValue) DoSomethingCalls() []struct { mock.lockDoSomething.RUnlock() return calls } + +// ResetDoSomethingCalls reset all the calls that were made to DoSomething. +func (mock *PanicOnNoReturnValue) ResetDoSomethingCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *PanicOnNoReturnValue) ResetCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go index 2ab5c70f..1c4649c6 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester does implement test.Requester. -// If this is not the case, regenerate this file with moq. -var _ test.Requester = &Requester{} - -// Requester is a mock implementation of test.Requester. +// Requester is a mock implementation of Requester. // // func TestSomethingThatUsesRequester(t *testing.T) { // -// // make and configure a mocked test.Requester +// // make and configure a mocked Requester // mockedRequester := &Requester{ // GetFunc: func(path string) (string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequester in code that requires test.Requester +// // use mockedRequester in code that requires Requester // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *Requester) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go index f6a423ad..fffb00a9 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester2 does implement test.Requester2. -// If this is not the case, regenerate this file with moq. -var _ test.Requester2 = &Requester2{} - -// Requester2 is a mock implementation of test.Requester2. +// Requester2 is a mock implementation of Requester2. // // func TestSomethingThatUsesRequester2(t *testing.T) { // -// // make and configure a mocked test.Requester2 +// // make and configure a mocked Requester2 // mockedRequester2 := &Requester2{ // GetFunc: func(path string) error { // panic("mock out the Get method") // }, // } // -// // use mockedRequester2 in code that requires test.Requester2 +// // use mockedRequester2 in code that requires Requester2 // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *Requester2) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester2) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester2) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go index ff14672e..f0ac545b 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester3 does implement test.Requester3. -// If this is not the case, regenerate this file with moq. -var _ test.Requester3 = &Requester3{} - -// Requester3 is a mock implementation of test.Requester3. +// Requester3 is a mock implementation of Requester3. // // func TestSomethingThatUsesRequester3(t *testing.T) { // -// // make and configure a mocked test.Requester3 +// // make and configure a mocked Requester3 // mockedRequester3 := &Requester3{ // GetFunc: func() error { // panic("mock out the Get method") // }, // } // -// // use mockedRequester3 in code that requires test.Requester3 +// // use mockedRequester3 in code that requires Requester3 // // and then make assertions. // // } @@ -67,3 +61,17 @@ func (mock *Requester3) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester3) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester3) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go index 2e40a741..454bd3be 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester4 does implement test.Requester4. -// If this is not the case, regenerate this file with moq. -var _ test.Requester4 = &Requester4{} - -// Requester4 is a mock implementation of test.Requester4. +// Requester4 is a mock implementation of Requester4. // // func TestSomethingThatUsesRequester4(t *testing.T) { // -// // make and configure a mocked test.Requester4 +// // make and configure a mocked Requester4 // mockedRequester4 := &Requester4{ // GetFunc: func() { // panic("mock out the Get method") // }, // } // -// // use mockedRequester4 in code that requires test.Requester4 +// // use mockedRequester4 in code that requires Requester4 // // and then make assertions. // // } @@ -67,3 +61,17 @@ func (mock *Requester4) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester4) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester4) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go index 35db68db..c2235f3e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go @@ -1,31 +1,25 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "encoding/json" "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsImport does implement test.RequesterArgSameAsImport. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterArgSameAsImport = &RequesterArgSameAsImport{} - -// RequesterArgSameAsImport is a mock implementation of test.RequesterArgSameAsImport. +// RequesterArgSameAsImport is a mock implementation of RequesterArgSameAsImport. // // func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { // -// // make and configure a mocked test.RequesterArgSameAsImport +// // make and configure a mocked RequesterArgSameAsImport // mockedRequesterArgSameAsImport := &RequesterArgSameAsImport{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsImport in code that requires test.RequesterArgSameAsImport +// // use mockedRequesterArgSameAsImport in code that requires RequesterArgSameAsImport // // and then make assertions. // // } @@ -75,3 +69,17 @@ func (mock *RequesterArgSameAsImport) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsImport) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsImport) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go index 528a7aa5..55e53b19 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go @@ -1,31 +1,25 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "encoding/json" "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsNamedImport does implement test.RequesterArgSameAsNamedImport. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterArgSameAsNamedImport = &RequesterArgSameAsNamedImport{} - -// RequesterArgSameAsNamedImport is a mock implementation of test.RequesterArgSameAsNamedImport. +// RequesterArgSameAsNamedImport is a mock implementation of RequesterArgSameAsNamedImport. // // func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { // -// // make and configure a mocked test.RequesterArgSameAsNamedImport +// // make and configure a mocked RequesterArgSameAsNamedImport // mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImport{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsNamedImport in code that requires test.RequesterArgSameAsNamedImport +// // use mockedRequesterArgSameAsNamedImport in code that requires RequesterArgSameAsNamedImport // // and then make assertions. // // } @@ -75,3 +69,17 @@ func (mock *RequesterArgSameAsNamedImport) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsNamedImport) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsNamedImport) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go index 661fe591..9df55853 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsPkg does implement test.RequesterArgSameAsPkg. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterArgSameAsPkg = &RequesterArgSameAsPkg{} - -// RequesterArgSameAsPkg is a mock implementation of test.RequesterArgSameAsPkg. +// RequesterArgSameAsPkg is a mock implementation of RequesterArgSameAsPkg. // // func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { // -// // make and configure a mocked test.RequesterArgSameAsPkg +// // make and configure a mocked RequesterArgSameAsPkg // mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkg{ // GetFunc: func(test string) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsPkg in code that requires test.RequesterArgSameAsPkg +// // use mockedRequesterArgSameAsPkg in code that requires RequesterArgSameAsPkg // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *RequesterArgSameAsPkg) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsPkg) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsPkg) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go index 6d973fa6..ce1ed103 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArray does implement test.RequesterArray. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterArray = &RequesterArray{} - -// RequesterArray is a mock implementation of test.RequesterArray. +// RequesterArray is a mock implementation of RequesterArray. // // func TestSomethingThatUsesRequesterArray(t *testing.T) { // -// // make and configure a mocked test.RequesterArray +// // make and configure a mocked RequesterArray // mockedRequesterArray := &RequesterArray{ // GetFunc: func(path string) ([2]string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArray in code that requires test.RequesterArray +// // use mockedRequesterArray in code that requires RequesterArray // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *RequesterArray) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArray) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArray) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go index d6bb8911..adee512c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterElided does implement test.RequesterElided. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterElided = &RequesterElided{} - -// RequesterElided is a mock implementation of test.RequesterElided. +// RequesterElided is a mock implementation of RequesterElided. // // func TestSomethingThatUsesRequesterElided(t *testing.T) { // -// // make and configure a mocked test.RequesterElided +// // make and configure a mocked RequesterElided // mockedRequesterElided := &RequesterElided{ // GetFunc: func(path string, url string) error { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterElided in code that requires test.RequesterElided +// // use mockedRequesterElided in code that requires RequesterElided // // and then make assertions. // // } @@ -80,3 +74,17 @@ func (mock *RequesterElided) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterElided) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterElided) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go index 6040e2c5..2dd932a5 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go @@ -1,31 +1,25 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "io" "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterIface does implement test.RequesterIface. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterIface = &RequesterIface{} - -// RequesterIface is a mock implementation of test.RequesterIface. +// RequesterIface is a mock implementation of RequesterIface. // // func TestSomethingThatUsesRequesterIface(t *testing.T) { // -// // make and configure a mocked test.RequesterIface +// // make and configure a mocked RequesterIface // mockedRequesterIface := &RequesterIface{ // GetFunc: func() io.Reader { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterIface in code that requires test.RequesterIface +// // use mockedRequesterIface in code that requires RequesterIface // // and then make assertions. // // } @@ -68,3 +62,17 @@ func (mock *RequesterIface) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterIface) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterIface) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go index 1853f7b9..4002c815 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go @@ -1,31 +1,25 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "net/http" "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterNS does implement test.RequesterNS. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterNS = &RequesterNS{} - -// RequesterNS is a mock implementation of test.RequesterNS. +// RequesterNS is a mock implementation of RequesterNS. // // func TestSomethingThatUsesRequesterNS(t *testing.T) { // -// // make and configure a mocked test.RequesterNS +// // make and configure a mocked RequesterNS // mockedRequesterNS := &RequesterNS{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterNS in code that requires test.RequesterNS +// // use mockedRequesterNS in code that requires RequesterNS // // and then make assertions. // // } @@ -75,3 +69,17 @@ func (mock *RequesterNS) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterNS) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterNS) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go index 7e98f69c..cec668a8 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterPtr does implement test.RequesterPtr. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterPtr = &RequesterPtr{} - -// RequesterPtr is a mock implementation of test.RequesterPtr. +// RequesterPtr is a mock implementation of RequesterPtr. // // func TestSomethingThatUsesRequesterPtr(t *testing.T) { // -// // make and configure a mocked test.RequesterPtr +// // make and configure a mocked RequesterPtr // mockedRequesterPtr := &RequesterPtr{ // GetFunc: func(path string) (*string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterPtr in code that requires test.RequesterPtr +// // use mockedRequesterPtr in code that requires RequesterPtr // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *RequesterPtr) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterPtr) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterPtr) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go index 3fed3c3f..0f866093 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go @@ -1,23 +1,17 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterReturnElided does implement test.RequesterReturnElided. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterReturnElided = &RequesterReturnElided{} - -// RequesterReturnElided is a mock implementation of test.RequesterReturnElided. +// RequesterReturnElided is a mock implementation of RequesterReturnElided. // // func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { // -// // make and configure a mocked test.RequesterReturnElided +// // make and configure a mocked RequesterReturnElided // mockedRequesterReturnElided := &RequesterReturnElided{ // GetFunc: func(path string) (int, int, int, error) { // panic("mock out the Get method") @@ -27,7 +21,7 @@ var _ test.RequesterReturnElided = &RequesterReturnElided{} // }, // } // -// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided +// // use mockedRequesterReturnElided in code that requires RequesterReturnElided // // and then make assertions. // // } @@ -87,6 +81,13 @@ func (mock *RequesterReturnElided) GetCalls() []struct { return calls } +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterReturnElided) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + // Put calls PutFunc. func (mock *RequesterReturnElided) Put(path string) (int, error) { if mock.PutFunc == nil { @@ -118,3 +119,21 @@ func (mock *RequesterReturnElided) PutCalls() []struct { mock.lockPut.RUnlock() return calls } + +// ResetPutCalls reset all the calls that were made to Put. +func (mock *RequesterReturnElided) ResetPutCalls() { + mock.lockPut.Lock() + mock.calls.Put = nil + mock.lockPut.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterReturnElided) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockPut.Lock() + mock.calls.Put = nil + mock.lockPut.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go index a55b94ab..79902c6b 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterSlice does implement test.RequesterSlice. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterSlice = &RequesterSlice{} - -// RequesterSlice is a mock implementation of test.RequesterSlice. +// RequesterSlice is a mock implementation of RequesterSlice. // // func TestSomethingThatUsesRequesterSlice(t *testing.T) { // -// // make and configure a mocked test.RequesterSlice +// // make and configure a mocked RequesterSlice // mockedRequesterSlice := &RequesterSlice{ // GetFunc: func(path string) ([]string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterSlice in code that requires test.RequesterSlice +// // use mockedRequesterSlice in code that requires RequesterSlice // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *RequesterSlice) GetCalls() []struct { mock.lockGet.RUnlock() return calls } + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterSlice) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterSlice) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go index 9be735df..3398b188 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go @@ -1,24 +1,18 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "io" "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterVariadic does implement test.RequesterVariadic. -// If this is not the case, regenerate this file with moq. -var _ test.RequesterVariadic = &RequesterVariadic{} - -// RequesterVariadic is a mock implementation of test.RequesterVariadic. +// RequesterVariadic is a mock implementation of RequesterVariadic. // // func TestSomethingThatUsesRequesterVariadic(t *testing.T) { // -// // make and configure a mocked test.RequesterVariadic +// // make and configure a mocked RequesterVariadic // mockedRequesterVariadic := &RequesterVariadic{ // GetFunc: func(values ...string) bool { // panic("mock out the Get method") @@ -34,7 +28,7 @@ var _ test.RequesterVariadic = &RequesterVariadic{} // }, // } // -// // use mockedRequesterVariadic in code that requires test.RequesterVariadic +// // use mockedRequesterVariadic in code that requires RequesterVariadic // // and then make assertions. // // } @@ -116,6 +110,13 @@ func (mock *RequesterVariadic) GetCalls() []struct { return calls } +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterVariadic) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + // MultiWriteToFile calls MultiWriteToFileFunc. func (mock *RequesterVariadic) MultiWriteToFile(filename string, w ...io.Writer) string { if mock.MultiWriteToFileFunc == nil { @@ -152,6 +153,13 @@ func (mock *RequesterVariadic) MultiWriteToFileCalls() []struct { return calls } +// ResetMultiWriteToFileCalls reset all the calls that were made to MultiWriteToFile. +func (mock *RequesterVariadic) ResetMultiWriteToFileCalls() { + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = nil + mock.lockMultiWriteToFile.Unlock() +} + // OneInterface calls OneInterfaceFunc. func (mock *RequesterVariadic) OneInterface(a ...interface{}) bool { if mock.OneInterfaceFunc == nil { @@ -184,6 +192,13 @@ func (mock *RequesterVariadic) OneInterfaceCalls() []struct { return calls } +// ResetOneInterfaceCalls reset all the calls that were made to OneInterface. +func (mock *RequesterVariadic) ResetOneInterfaceCalls() { + mock.lockOneInterface.Lock() + mock.calls.OneInterface = nil + mock.lockOneInterface.Unlock() +} + // Sprintf calls SprintfFunc. func (mock *RequesterVariadic) Sprintf(format string, a ...interface{}) string { if mock.SprintfFunc == nil { @@ -219,3 +234,29 @@ func (mock *RequesterVariadic) SprintfCalls() []struct { mock.lockSprintf.RUnlock() return calls } + +// ResetSprintfCalls reset all the calls that were made to Sprintf. +func (mock *RequesterVariadic) ResetSprintfCalls() { + mock.lockSprintf.Lock() + mock.calls.Sprintf = nil + mock.lockSprintf.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterVariadic) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = nil + mock.lockMultiWriteToFile.Unlock() + + mock.lockOneInterface.Lock() + mock.calls.OneInterface = nil + mock.lockOneInterface.Unlock() + + mock.lockSprintf.Lock() + mock.calls.Sprintf = nil + mock.lockSprintf.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go index 08e5e4a5..22109317 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Sibling does implement test.Sibling. -// If this is not the case, regenerate this file with moq. -var _ test.Sibling = &Sibling{} - -// Sibling is a mock implementation of test.Sibling. +// Sibling is a mock implementation of Sibling. // // func TestSomethingThatUsesSibling(t *testing.T) { // -// // make and configure a mocked test.Sibling +// // make and configure a mocked Sibling // mockedSibling := &Sibling{ // DoSomethingFunc: func() { // panic("mock out the DoSomething method") // }, // } // -// // use mockedSibling in code that requires test.Sibling +// // use mockedSibling in code that requires Sibling // // and then make assertions. // // } @@ -67,3 +61,17 @@ func (mock *Sibling) DoSomethingCalls() []struct { mock.lockDoSomething.RUnlock() return calls } + +// ResetDoSomethingCalls reset all the calls that were made to DoSomething. +func (mock *Sibling) ResetDoSomethingCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Sibling) ResetCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go index b3967ef6..333933f9 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that StructWithTag does implement test.StructWithTag. -// If this is not the case, regenerate this file with moq. -var _ test.StructWithTag = &StructWithTag{} - -// StructWithTag is a mock implementation of test.StructWithTag. +// StructWithTag is a mock implementation of StructWithTag. // // func TestSomethingThatUsesStructWithTag(t *testing.T) { // -// // make and configure a mocked test.StructWithTag +// // make and configure a mocked StructWithTag // mockedStructWithTag := &StructWithTag{ // MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { // panic("mock out the MethodA method") // }, // } // -// // use mockedStructWithTag in code that requires test.StructWithTag +// // use mockedStructWithTag in code that requires StructWithTag // // and then make assertions. // // } @@ -98,3 +92,17 @@ func (mock *StructWithTag) MethodACalls() []struct { mock.lockMethodA.RUnlock() return calls } + +// ResetMethodACalls reset all the calls that were made to MethodA. +func (mock *StructWithTag) ResetMethodACalls() { + mock.lockMethodA.Lock() + mock.calls.MethodA = nil + mock.lockMethodA.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *StructWithTag) ResetCalls() { + mock.lockMethodA.Lock() + mock.calls.MethodA = nil + mock.lockMethodA.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go index f0690460..e9e32372 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go @@ -1,7 +1,7 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" @@ -9,22 +9,18 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that UsesOtherPkgIface does implement test.UsesOtherPkgIface. -// If this is not the case, regenerate this file with moq. -var _ test.UsesOtherPkgIface = &UsesOtherPkgIface{} - -// UsesOtherPkgIface is a mock implementation of test.UsesOtherPkgIface. +// UsesOtherPkgIface is a mock implementation of UsesOtherPkgIface. // // func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { // -// // make and configure a mocked test.UsesOtherPkgIface +// // make and configure a mocked UsesOtherPkgIface // mockedUsesOtherPkgIface := &UsesOtherPkgIface{ // DoSomethingElseFunc: func(obj test.Sibling) { // panic("mock out the DoSomethingElse method") // }, // } // -// // use mockedUsesOtherPkgIface in code that requires test.UsesOtherPkgIface +// // use mockedUsesOtherPkgIface in code that requires UsesOtherPkgIface // // and then make assertions. // // } @@ -74,3 +70,17 @@ func (mock *UsesOtherPkgIface) DoSomethingElseCalls() []struct { mock.lockDoSomethingElse.RUnlock() return calls } + +// ResetDoSomethingElseCalls reset all the calls that were made to DoSomethingElse. +func (mock *UsesOtherPkgIface) ResetDoSomethingElseCalls() { + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = nil + mock.lockDoSomethingElse.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *UsesOtherPkgIface) ResetCalls() { + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = nil + mock.lockDoSomethingElse.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go index f148907e..65620671 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Variadic does implement test.Variadic. -// If this is not the case, regenerate this file with moq. -var _ test.Variadic = &Variadic{} - -// Variadic is a mock implementation of test.Variadic. +// Variadic is a mock implementation of Variadic. // // func TestSomethingThatUsesVariadic(t *testing.T) { // -// // make and configure a mocked test.Variadic +// // make and configure a mocked Variadic // mockedVariadic := &Variadic{ // VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { // panic("mock out the VariadicFunction method") // }, // } // -// // use mockedVariadic in code that requires test.Variadic +// // use mockedVariadic in code that requires Variadic // // and then make assertions. // // } @@ -80,3 +74,17 @@ func (mock *Variadic) VariadicFunctionCalls() []struct { mock.lockVariadicFunction.RUnlock() return calls } + +// ResetVariadicFunctionCalls reset all the calls that were made to VariadicFunction. +func (mock *Variadic) ResetVariadicFunctionCalls() { + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = nil + mock.lockVariadicFunction.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Variadic) ResetCalls() { + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = nil + mock.lockVariadicFunction.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go index ed2e3d6d..fdfca4a5 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that VariadicNoReturnInterface does implement test.VariadicNoReturnInterface. -// If this is not the case, regenerate this file with moq. -var _ test.VariadicNoReturnInterface = &VariadicNoReturnInterface{} - -// VariadicNoReturnInterface is a mock implementation of test.VariadicNoReturnInterface. +// VariadicNoReturnInterface is a mock implementation of VariadicNoReturnInterface. // // func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { // -// // make and configure a mocked test.VariadicNoReturnInterface +// // make and configure a mocked VariadicNoReturnInterface // mockedVariadicNoReturnInterface := &VariadicNoReturnInterface{ // VariadicNoReturnFunc: func(j int, is ...interface{}) { // panic("mock out the VariadicNoReturn method") // }, // } // -// // use mockedVariadicNoReturnInterface in code that requires test.VariadicNoReturnInterface +// // use mockedVariadicNoReturnInterface in code that requires VariadicNoReturnInterface // // and then make assertions. // // } @@ -80,3 +74,17 @@ func (mock *VariadicNoReturnInterface) VariadicNoReturnCalls() []struct { mock.lockVariadicNoReturn.RUnlock() return calls } + +// ResetVariadicNoReturnCalls reset all the calls that were made to VariadicNoReturn. +func (mock *VariadicNoReturnInterface) ResetVariadicNoReturnCalls() { + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = nil + mock.lockVariadicNoReturn.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *VariadicNoReturnInterface) ResetCalls() { + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = nil + mock.lockVariadicNoReturn.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go index 9ad07c7d..1bf44070 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go @@ -1,30 +1,24 @@ // Code generated by mockery; DO NOT EDIT. // github.com/vektra/mockery -package testfoo +package test import ( "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that VariadicReturnFunc does implement test.VariadicReturnFunc. -// If this is not the case, regenerate this file with moq. -var _ test.VariadicReturnFunc = &VariadicReturnFunc{} - -// VariadicReturnFunc is a mock implementation of test.VariadicReturnFunc. +// VariadicReturnFunc is a mock implementation of VariadicReturnFunc. // // func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { // -// // make and configure a mocked test.VariadicReturnFunc +// // make and configure a mocked VariadicReturnFunc // mockedVariadicReturnFunc := &VariadicReturnFunc{ // SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { // panic("mock out the SampleMethod method") // }, // } // -// // use mockedVariadicReturnFunc in code that requires test.VariadicReturnFunc +// // use mockedVariadicReturnFunc in code that requires VariadicReturnFunc // // and then make assertions. // // } @@ -74,3 +68,17 @@ func (mock *VariadicReturnFunc) SampleMethodCalls() []struct { mock.lockSampleMethod.RUnlock() return calls } + +// ResetSampleMethodCalls reset all the calls that were made to SampleMethod. +func (mock *VariadicReturnFunc) ResetSampleMethodCalls() { + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = nil + mock.lockSampleMethod.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *VariadicReturnFunc) ResetCalls() { + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = nil + mock.lockSampleMethod.Unlock() +} diff --git a/pkg/config/config.go b/pkg/config/config.go index fa34d8fc..84c2104a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -33,7 +33,7 @@ type Interface struct { type Config struct { All bool `mapstructure:"all"` - MockBuildTags string `mapstructure:"mock-build-tags"` + BoilerplateFile string `mapstructure:"boilerplate-file"` BuildTags string `mapstructure:"tags"` Case string `mapstructure:"case"` Config string `mapstructure:"config"` @@ -42,6 +42,7 @@ type Config struct { DisableConfigSearch bool `mapstructure:"disable-config-search"` DisableVersionString bool `mapstructure:"disable-version-string"` DryRun bool `mapstructure:"dry-run"` + Exclude []string `mapstructure:"exclude"` ExcludeRegex string `mapstructure:"exclude-regex"` Exported bool `mapstructure:"exported"` FileName string `mapstructure:"filename"` @@ -52,6 +53,7 @@ type Config struct { InPackageSuffix bool `mapstructure:"inpackage-suffix"` KeepTree bool `mapstructure:"keeptree"` LogLevel string `mapstructure:"log-level"` + MockBuildTags string `mapstructure:"mock-build-tags"` MockName string `mapstructure:"mockname"` Name string `mapstructure:"name"` Note string `mapstructure:"note"` @@ -63,19 +65,18 @@ type Config struct { Profile string `mapstructure:"profile"` Quiet bool `mapstructure:"quiet"` Recursive bool `mapstructure:"recursive"` - Exclude []string `mapstructure:"exclude"` + ReplaceType []string `mapstructure:"replace-type"` SkipEnsure bool `mapstructure:"skip-ensure"` SrcPkg string `mapstructure:"srcpkg"` Style string `mapstructure:"style"` - BoilerplateFile string `mapstructure:"boilerplate-file"` // StructName overrides the name given to the mock struct and should only be nonempty // when generating for an exact match (non regex expression in -name). - StructName string `mapstructure:"structname"` - TestOnly bool `mapstructure:"testonly"` - UnrollVariadic bool `mapstructure:"unroll-variadic"` - Version bool `mapstructure:"version"` - WithExpecter bool `mapstructure:"with-expecter"` - ReplaceType []string `mapstructure:"replace-type"` + StructName string `mapstructure:"structname"` + TemplateMap map[string]any `mapstructure:"template-map"` + TestOnly bool `mapstructure:"testonly"` + UnrollVariadic bool `mapstructure:"unroll-variadic"` + Version bool `mapstructure:"version"` + WithExpecter bool `mapstructure:"with-expecter"` // Viper throws away case-sensitivity when it marshals into this struct. This // destroys necessary information we need, specifically around interface names. diff --git a/pkg/generator/template_generator.go b/pkg/generator/template_generator.go index 1dce0b79..806d29e9 100644 --- a/pkg/generator/template_generator.go +++ b/pkg/generator/template_generator.go @@ -140,11 +140,10 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac }, } data := template.Data{ - PkgName: ifaceConfig.Outpkg, - Mocks: mockData, - StubImpl: false, - SkipEnsure: false, - WithResets: false, + PkgName: ifaceConfig.Outpkg, + Mocks: mockData, + TemplateMap: ifaceConfig.TemplateMap, + StubImpl: false, } if data.MocksSomeMethod() { log.Debug().Msg("interface mocks some method, importing sync package") diff --git a/pkg/template/moq.templ b/pkg/template/moq.templ index 5770c443..0dda715a 100644 --- a/pkg/template/moq.templ +++ b/pkg/template/moq.templ @@ -11,7 +11,7 @@ import ( {{range $i, $mock := .Mocks -}} -{{- if not $.SkipEnsure -}} +{{- if not (index $.TemplateMap "skip-ensure") -}} // Ensure, that {{.MockName}} does implement {{$.SrcPkgQualifier}}{{.InterfaceName}}. // If this is not the case, regenerate this file with moq. var _ {{$.SrcPkgQualifier}}{{.InterfaceName -}} @@ -77,14 +77,8 @@ type {{.MockName}} } {{range .Methods}} // {{.Name}} calls {{.Name}}Func. -func (mock *{{$mock.MockName}} -{{- if $mock.TypeParams -}} - [{{- range $index, $param := $mock.TypeParams}} - {{- if $index}}, {{end}}{{$param.Name | Exported}} - {{- end -}}] -{{- end -}} -) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { -{{- if not $.StubImpl}} +func (mock *{{$mock.MockName}}{{ $mock | TypeInstantiation }}) {{.Name}}({{.ArgList}}) {{.ReturnArgTypeList}} { +{{- if not (index $.TemplateMap "stub-impl") }} if mock.{{.Name}}Func == nil { panic("{{$mock.MockName}}.{{.Name}}Func: method is nil but {{$mock.InterfaceName}}.{{.Name}} was just called") } @@ -102,7 +96,7 @@ func (mock *{{$mock.MockName}} mock.calls.{{.Name}} = append(mock.calls.{{.Name}}, callInfo) mock.lock{{.Name}}.Unlock() {{- if .Returns}} - {{- if $.StubImpl}} + {{- if (index $.TemplateMap "stub-impl") }} if mock.{{.Name}}Func == nil { var ( {{- range .Returns}} @@ -114,7 +108,7 @@ func (mock *{{$mock.MockName}} {{- end}} return mock.{{.Name}}Func({{.ArgCallList}}) {{- else}} - {{- if $.StubImpl}} + {{- if (index $.TemplateMap "stub-impl") }} if mock.{{.Name}}Func == nil { return } @@ -127,13 +121,7 @@ func (mock *{{$mock.MockName}} // Check the length with: // // len(mocked{{$mock.InterfaceName}}.{{.Name}}Calls()) -func (mock *{{$mock.MockName}} -{{- if $mock.TypeParams -}} - [{{- range $index, $param := $mock.TypeParams}} - {{- if $index}}, {{end}}{{$param.Name | Exported}} - {{- end -}}] -{{- end -}} -) {{.Name}}Calls() []struct { +func (mock *{{$mock.MockName}}{{ $mock | TypeInstantiation }}) {{.Name}}Calls() []struct { {{- range .Params}} {{.Name | Exported}} {{.TypeString}} {{- end}} @@ -148,18 +136,18 @@ func (mock *{{$mock.MockName}} mock.lock{{.Name}}.RUnlock() return calls } -{{- if $.WithResets}} +{{- if index $.TemplateMap "with-resets" }} // Reset{{.Name}}Calls reset all the calls that were made to {{.Name}}. -func (mock *{{$mock.MockName}}) Reset{{.Name}}Calls() { +func (mock *{{$mock.MockName}}{{ $mock | TypeInstantiation }}) Reset{{.Name}}Calls() { mock.lock{{.Name}}.Lock() mock.calls.{{.Name}} = nil mock.lock{{.Name}}.Unlock() } {{end}} {{end -}} -{{- if $.WithResets}} +{{- if index $.TemplateMap "with-resets" }} // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *{{$mock.MockName}}) ResetCalls() { +func (mock *{{$mock.MockName}}{{ $mock | TypeInstantiation }}) ResetCalls() { {{- range .Methods}} mock.lock{{.Name}}.Lock() mock.calls.{{.Name}} = nil diff --git a/pkg/template/template.go b/pkg/template/template.go index e380afb3..e1a59a15 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -53,6 +53,18 @@ var golintInitialisms = []string{ "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", } +func exported(s string) string { + if s == "" { + return "" + } + for _, initialism := range golintInitialisms { + if strings.ToUpper(s) == initialism { + return initialism + } + } + return strings.ToUpper(s[0:1]) + s[1:] +} + var templateFuncs = template.FuncMap{ "ImportStatement": func(imprt *registry.Package) string { if imprt.Alias == "" { @@ -69,15 +81,19 @@ var templateFuncs = template.FuncMap{ return "sync" }, - "Exported": func(s string) string { - if s == "" { + "Exported": exported, + "TypeInstantiation": func(m MockData) string { + if len(m.TypeParams) == 0 { return "" } - for _, initialism := range golintInitialisms { - if strings.ToUpper(s) == initialism { - return initialism + s := "[" + for idx, param := range m.TypeParams { + if idx != 0 { + s += ", " } + s += exported(param.Name()) } - return strings.ToUpper(s[0:1]) + s[1:] + s += "]" + return s }, } diff --git a/pkg/template/template_data.go b/pkg/template/template_data.go index 0a27a245..5bf5a740 100644 --- a/pkg/template/template_data.go +++ b/pkg/template/template_data.go @@ -14,6 +14,7 @@ type Data struct { SrcPkgQualifier string Imports []*registry.Package Mocks []MockData + TemplateMap map[string]any StubImpl bool SkipEnsure bool WithResets bool From db5f5a6ed2cecb048fad72a1c01b5c8da584d484 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 12:58:57 -0600 Subject: [PATCH 36/50] check err of generateMockery --- pkg/outputter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/outputter.go b/pkg/outputter.go index d92eb2b0..2fdba2c5 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -329,7 +329,9 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } if interfaceConfig.Style == "mockery" { ifaceLog.Debug().Msg("generating mockery mocks") - o.generateMockery(ctx, iface, interfaceConfig) + if err := o.generateMockery(ctx, iface, interfaceConfig); err != nil { + return err + } continue } logging.WarnAlpha(ifaceCtx, "usage mock styles other than mockery is currently in an alpha state.", nil) From 05f2c4dafa4b2dcb8717ef0d270841992ed57ee0 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 13:58:28 -0600 Subject: [PATCH 37/50] update moq mocks --- .../vektra/mockery/v2/pkg/fixtures/A.go | 16 +++---- .../mockery/v2/pkg/fixtures/AsyncProducer.go | 32 ++++++------- .../vektra/mockery/v2/pkg/fixtures/Blank.go | 16 +++---- .../mockery/v2/pkg/fixtures/ConsulLock.go | 24 +++++----- .../mockery/v2/pkg/fixtures/EmbeddedGet.go | 16 +++---- .../vektra/mockery/v2/pkg/fixtures/Example.go | 24 +++++----- .../mockery/v2/pkg/fixtures/Expecter.go | 48 +++++++++---------- .../vektra/mockery/v2/pkg/fixtures/Fooer.go | 32 ++++++------- .../v2/pkg/fixtures/FuncArgsCollision.go | 16 +++---- .../mockery/v2/pkg/fixtures/GetGeneric.go | 16 +++---- .../vektra/mockery/v2/pkg/fixtures/GetInt.go | 16 +++---- .../fixtures/HasConflictingNestedImports.go | 24 +++++----- .../v2/pkg/fixtures/ImportsSameAsPackage.go | 32 ++++++------- .../mockery/v2/pkg/fixtures/KeyManager.go | 16 +++---- .../vektra/mockery/v2/pkg/fixtures/MapFunc.go | 16 +++---- .../mockery/v2/pkg/fixtures/MapToInterface.go | 16 +++---- .../mockery/v2/pkg/fixtures/MyReader.go | 16 +++---- .../v2/pkg/fixtures/PanicOnNoReturnValue.go | 16 +++---- .../mockery/v2/pkg/fixtures/Requester.go | 16 +++---- .../mockery/v2/pkg/fixtures/Requester2.go | 16 +++---- .../mockery/v2/pkg/fixtures/Requester3.go | 16 +++---- .../mockery/v2/pkg/fixtures/Requester4.go | 16 +++---- .../pkg/fixtures/RequesterArgSameAsImport.go | 16 +++---- .../fixtures/RequesterArgSameAsNamedImport.go | 16 +++---- .../v2/pkg/fixtures/RequesterArgSameAsPkg.go | 16 +++---- .../mockery/v2/pkg/fixtures/RequesterArray.go | 16 +++---- .../v2/pkg/fixtures/RequesterElided.go | 16 +++---- .../mockery/v2/pkg/fixtures/RequesterIface.go | 16 +++---- .../mockery/v2/pkg/fixtures/RequesterNS.go | 16 +++---- .../mockery/v2/pkg/fixtures/RequesterPtr.go | 16 +++---- .../v2/pkg/fixtures/RequesterReturnElided.go | 24 +++++----- .../mockery/v2/pkg/fixtures/RequesterSlice.go | 16 +++---- .../v2/pkg/fixtures/RequesterVariadic.go | 40 ++++++++-------- .../vektra/mockery/v2/pkg/fixtures/Sibling.go | 16 +++---- .../mockery/v2/pkg/fixtures/StructWithTag.go | 16 +++---- .../v2/pkg/fixtures/UsesOtherPkgIface.go | 16 +++---- .../mockery/v2/pkg/fixtures/Variadic.go | 16 +++---- .../pkg/fixtures/VariadicNoReturnInterface.go | 16 +++---- .../v2/pkg/fixtures/VariadicReturnFunc.go | 16 +++---- 39 files changed, 380 insertions(+), 380 deletions(-) diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go index 279586d1..cb35a530 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go @@ -9,12 +9,12 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// A is a mock implementation of A. +// AMock is a mock implementation of A. // // func TestSomethingThatUsesA(t *testing.T) { // // // make and configure a mocked A -// mockedA := &A{ +// mockedA := &AMock{ // CallFunc: func() (test.B, error) { // panic("mock out the Call method") // }, @@ -24,7 +24,7 @@ import ( // // and then make assertions. // // } -type A struct { +type AMock struct { // CallFunc mocks the Call method. CallFunc func() (test.B, error) @@ -38,9 +38,9 @@ type A struct { } // Call calls CallFunc. -func (mock *A) Call() (test.B, error) { +func (mock *AMock) Call() (test.B, error) { if mock.CallFunc == nil { - panic("A.CallFunc: method is nil but A.Call was just called") + panic("AMock.CallFunc: method is nil but A.Call was just called") } callInfo := struct { }{} @@ -54,7 +54,7 @@ func (mock *A) Call() (test.B, error) { // Check the length with: // // len(mockedA.CallCalls()) -func (mock *A) CallCalls() []struct { +func (mock *AMock) CallCalls() []struct { } { var calls []struct { } @@ -65,14 +65,14 @@ func (mock *A) CallCalls() []struct { } // ResetCallCalls reset all the calls that were made to Call. -func (mock *A) ResetCallCalls() { +func (mock *AMock) ResetCallCalls() { mock.lockCall.Lock() mock.calls.Call = nil mock.lockCall.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *A) ResetCalls() { +func (mock *AMock) ResetCalls() { mock.lockCall.Lock() mock.calls.Call = nil mock.lockCall.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go index c86ec9e3..b1a95585 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go @@ -7,12 +7,12 @@ import ( "sync" ) -// AsyncProducer is a mock implementation of AsyncProducer. +// AsyncProducerMock is a mock implementation of AsyncProducer. // // func TestSomethingThatUsesAsyncProducer(t *testing.T) { // // // make and configure a mocked AsyncProducer -// mockedAsyncProducer := &AsyncProducer{ +// mockedAsyncProducer := &AsyncProducerMock{ // InputFunc: func() chan<- bool { // panic("mock out the Input method") // }, @@ -28,7 +28,7 @@ import ( // // and then make assertions. // // } -type AsyncProducer struct { +type AsyncProducerMock struct { // InputFunc mocks the Input method. InputFunc func() chan<- bool @@ -56,9 +56,9 @@ type AsyncProducer struct { } // Input calls InputFunc. -func (mock *AsyncProducer) Input() chan<- bool { +func (mock *AsyncProducerMock) Input() chan<- bool { if mock.InputFunc == nil { - panic("AsyncProducer.InputFunc: method is nil but AsyncProducer.Input was just called") + panic("AsyncProducerMock.InputFunc: method is nil but AsyncProducer.Input was just called") } callInfo := struct { }{} @@ -72,7 +72,7 @@ func (mock *AsyncProducer) Input() chan<- bool { // Check the length with: // // len(mockedAsyncProducer.InputCalls()) -func (mock *AsyncProducer) InputCalls() []struct { +func (mock *AsyncProducerMock) InputCalls() []struct { } { var calls []struct { } @@ -83,16 +83,16 @@ func (mock *AsyncProducer) InputCalls() []struct { } // ResetInputCalls reset all the calls that were made to Input. -func (mock *AsyncProducer) ResetInputCalls() { +func (mock *AsyncProducerMock) ResetInputCalls() { mock.lockInput.Lock() mock.calls.Input = nil mock.lockInput.Unlock() } // Output calls OutputFunc. -func (mock *AsyncProducer) Output() <-chan bool { +func (mock *AsyncProducerMock) Output() <-chan bool { if mock.OutputFunc == nil { - panic("AsyncProducer.OutputFunc: method is nil but AsyncProducer.Output was just called") + panic("AsyncProducerMock.OutputFunc: method is nil but AsyncProducer.Output was just called") } callInfo := struct { }{} @@ -106,7 +106,7 @@ func (mock *AsyncProducer) Output() <-chan bool { // Check the length with: // // len(mockedAsyncProducer.OutputCalls()) -func (mock *AsyncProducer) OutputCalls() []struct { +func (mock *AsyncProducerMock) OutputCalls() []struct { } { var calls []struct { } @@ -117,16 +117,16 @@ func (mock *AsyncProducer) OutputCalls() []struct { } // ResetOutputCalls reset all the calls that were made to Output. -func (mock *AsyncProducer) ResetOutputCalls() { +func (mock *AsyncProducerMock) ResetOutputCalls() { mock.lockOutput.Lock() mock.calls.Output = nil mock.lockOutput.Unlock() } // Whatever calls WhateverFunc. -func (mock *AsyncProducer) Whatever() chan bool { +func (mock *AsyncProducerMock) Whatever() chan bool { if mock.WhateverFunc == nil { - panic("AsyncProducer.WhateverFunc: method is nil but AsyncProducer.Whatever was just called") + panic("AsyncProducerMock.WhateverFunc: method is nil but AsyncProducer.Whatever was just called") } callInfo := struct { }{} @@ -140,7 +140,7 @@ func (mock *AsyncProducer) Whatever() chan bool { // Check the length with: // // len(mockedAsyncProducer.WhateverCalls()) -func (mock *AsyncProducer) WhateverCalls() []struct { +func (mock *AsyncProducerMock) WhateverCalls() []struct { } { var calls []struct { } @@ -151,14 +151,14 @@ func (mock *AsyncProducer) WhateverCalls() []struct { } // ResetWhateverCalls reset all the calls that were made to Whatever. -func (mock *AsyncProducer) ResetWhateverCalls() { +func (mock *AsyncProducerMock) ResetWhateverCalls() { mock.lockWhatever.Lock() mock.calls.Whatever = nil mock.lockWhatever.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *AsyncProducer) ResetCalls() { +func (mock *AsyncProducerMock) ResetCalls() { mock.lockInput.Lock() mock.calls.Input = nil mock.lockInput.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go index dae12d57..d32c77d1 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Blank is a mock implementation of Blank. +// BlankMock is a mock implementation of Blank. // // func TestSomethingThatUsesBlank(t *testing.T) { // // // make and configure a mocked Blank -// mockedBlank := &Blank{ +// mockedBlank := &BlankMock{ // CreateFunc: func(x interface{}) error { // panic("mock out the Create method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Blank struct { +type BlankMock struct { // CreateFunc mocks the Create method. CreateFunc func(x interface{}) error @@ -38,9 +38,9 @@ type Blank struct { } // Create calls CreateFunc. -func (mock *Blank) Create(x interface{}) error { +func (mock *BlankMock) Create(x interface{}) error { if mock.CreateFunc == nil { - panic("Blank.CreateFunc: method is nil but Blank.Create was just called") + panic("BlankMock.CreateFunc: method is nil but Blank.Create was just called") } callInfo := struct { X interface{} @@ -57,7 +57,7 @@ func (mock *Blank) Create(x interface{}) error { // Check the length with: // // len(mockedBlank.CreateCalls()) -func (mock *Blank) CreateCalls() []struct { +func (mock *BlankMock) CreateCalls() []struct { X interface{} } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *Blank) CreateCalls() []struct { } // ResetCreateCalls reset all the calls that were made to Create. -func (mock *Blank) ResetCreateCalls() { +func (mock *BlankMock) ResetCreateCalls() { mock.lockCreate.Lock() mock.calls.Create = nil mock.lockCreate.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Blank) ResetCalls() { +func (mock *BlankMock) ResetCalls() { mock.lockCreate.Lock() mock.calls.Create = nil mock.lockCreate.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go index e41959a4..66abf534 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go @@ -7,12 +7,12 @@ import ( "sync" ) -// ConsulLock is a mock implementation of ConsulLock. +// ConsulLockMock is a mock implementation of ConsulLock. // // func TestSomethingThatUsesConsulLock(t *testing.T) { // // // make and configure a mocked ConsulLock -// mockedConsulLock := &ConsulLock{ +// mockedConsulLock := &ConsulLockMock{ // LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { // panic("mock out the Lock method") // }, @@ -25,7 +25,7 @@ import ( // // and then make assertions. // // } -type ConsulLock struct { +type ConsulLockMock struct { // LockFunc mocks the Lock method. LockFunc func(valCh <-chan struct{}) (<-chan struct{}, error) @@ -48,9 +48,9 @@ type ConsulLock struct { } // Lock calls LockFunc. -func (mock *ConsulLock) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { +func (mock *ConsulLockMock) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { if mock.LockFunc == nil { - panic("ConsulLock.LockFunc: method is nil but ConsulLock.Lock was just called") + panic("ConsulLockMock.LockFunc: method is nil but ConsulLock.Lock was just called") } callInfo := struct { ValCh <-chan struct{} @@ -67,7 +67,7 @@ func (mock *ConsulLock) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { // Check the length with: // // len(mockedConsulLock.LockCalls()) -func (mock *ConsulLock) LockCalls() []struct { +func (mock *ConsulLockMock) LockCalls() []struct { ValCh <-chan struct{} } { var calls []struct { @@ -80,16 +80,16 @@ func (mock *ConsulLock) LockCalls() []struct { } // ResetLockCalls reset all the calls that were made to Lock. -func (mock *ConsulLock) ResetLockCalls() { +func (mock *ConsulLockMock) ResetLockCalls() { mock.lockLock.Lock() mock.calls.Lock = nil mock.lockLock.Unlock() } // Unlock calls UnlockFunc. -func (mock *ConsulLock) Unlock() error { +func (mock *ConsulLockMock) Unlock() error { if mock.UnlockFunc == nil { - panic("ConsulLock.UnlockFunc: method is nil but ConsulLock.Unlock was just called") + panic("ConsulLockMock.UnlockFunc: method is nil but ConsulLock.Unlock was just called") } callInfo := struct { }{} @@ -103,7 +103,7 @@ func (mock *ConsulLock) Unlock() error { // Check the length with: // // len(mockedConsulLock.UnlockCalls()) -func (mock *ConsulLock) UnlockCalls() []struct { +func (mock *ConsulLockMock) UnlockCalls() []struct { } { var calls []struct { } @@ -114,14 +114,14 @@ func (mock *ConsulLock) UnlockCalls() []struct { } // ResetUnlockCalls reset all the calls that were made to Unlock. -func (mock *ConsulLock) ResetUnlockCalls() { +func (mock *ConsulLockMock) ResetUnlockCalls() { mock.lockUnlock.Lock() mock.calls.Unlock = nil mock.lockUnlock.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ConsulLock) ResetCalls() { +func (mock *ConsulLockMock) ResetCalls() { mock.lockLock.Lock() mock.calls.Lock = nil mock.lockLock.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go index 4e92eb91..41d69d69 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go @@ -9,12 +9,12 @@ import ( "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// EmbeddedGet is a mock implementation of EmbeddedGet. +// EmbeddedGetMock is a mock implementation of EmbeddedGet. // // func TestSomethingThatUsesEmbeddedGet(t *testing.T) { // // // make and configure a mocked EmbeddedGet -// mockedEmbeddedGet := &EmbeddedGet{ +// mockedEmbeddedGet := &EmbeddedGetMock{ // GetFunc: func() T { // panic("mock out the Get method") // }, @@ -24,7 +24,7 @@ import ( // // and then make assertions. // // } -type EmbeddedGet[T constraints.Signed] struct { +type EmbeddedGetMock[T constraints.Signed] struct { // GetFunc mocks the Get method. GetFunc func() T @@ -38,9 +38,9 @@ type EmbeddedGet[T constraints.Signed] struct { } // Get calls GetFunc. -func (mock *EmbeddedGet[T]) Get() T { +func (mock *EmbeddedGetMock[T]) Get() T { if mock.GetFunc == nil { - panic("EmbeddedGet.GetFunc: method is nil but EmbeddedGet.Get was just called") + panic("EmbeddedGetMock.GetFunc: method is nil but EmbeddedGet.Get was just called") } callInfo := struct { }{} @@ -54,7 +54,7 @@ func (mock *EmbeddedGet[T]) Get() T { // Check the length with: // // len(mockedEmbeddedGet.GetCalls()) -func (mock *EmbeddedGet[T]) GetCalls() []struct { +func (mock *EmbeddedGetMock[T]) GetCalls() []struct { } { var calls []struct { } @@ -65,14 +65,14 @@ func (mock *EmbeddedGet[T]) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *EmbeddedGet[T]) ResetGetCalls() { +func (mock *EmbeddedGetMock[T]) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *EmbeddedGet[T]) ResetCalls() { +func (mock *EmbeddedGetMock[T]) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go index c2e8c675..343150d8 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go @@ -10,12 +10,12 @@ import ( my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// Example is a mock implementation of Example. +// ExampleMock is a mock implementation of Example. // // func TestSomethingThatUsesExample(t *testing.T) { // // // make and configure a mocked Example -// mockedExample := &Example{ +// mockedExample := &ExampleMock{ // AFunc: func() http.Flusher { // panic("mock out the A method") // }, @@ -28,7 +28,7 @@ import ( // // and then make assertions. // // } -type Example struct { +type ExampleMock struct { // AFunc mocks the A method. AFunc func() http.Flusher @@ -51,9 +51,9 @@ type Example struct { } // A calls AFunc. -func (mock *Example) A() http.Flusher { +func (mock *ExampleMock) A() http.Flusher { if mock.AFunc == nil { - panic("Example.AFunc: method is nil but Example.A was just called") + panic("ExampleMock.AFunc: method is nil but Example.A was just called") } callInfo := struct { }{} @@ -67,7 +67,7 @@ func (mock *Example) A() http.Flusher { // Check the length with: // // len(mockedExample.ACalls()) -func (mock *Example) ACalls() []struct { +func (mock *ExampleMock) ACalls() []struct { } { var calls []struct { } @@ -78,16 +78,16 @@ func (mock *Example) ACalls() []struct { } // ResetACalls reset all the calls that were made to A. -func (mock *Example) ResetACalls() { +func (mock *ExampleMock) ResetACalls() { mock.lockA.Lock() mock.calls.A = nil mock.lockA.Unlock() } // B calls BFunc. -func (mock *Example) B(fixtureshttp string) my_http.MyStruct { +func (mock *ExampleMock) B(fixtureshttp string) my_http.MyStruct { if mock.BFunc == nil { - panic("Example.BFunc: method is nil but Example.B was just called") + panic("ExampleMock.BFunc: method is nil but Example.B was just called") } callInfo := struct { Fixtureshttp string @@ -104,7 +104,7 @@ func (mock *Example) B(fixtureshttp string) my_http.MyStruct { // Check the length with: // // len(mockedExample.BCalls()) -func (mock *Example) BCalls() []struct { +func (mock *ExampleMock) BCalls() []struct { Fixtureshttp string } { var calls []struct { @@ -117,14 +117,14 @@ func (mock *Example) BCalls() []struct { } // ResetBCalls reset all the calls that were made to B. -func (mock *Example) ResetBCalls() { +func (mock *ExampleMock) ResetBCalls() { mock.lockB.Lock() mock.calls.B = nil mock.lockB.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Example) ResetCalls() { +func (mock *ExampleMock) ResetCalls() { mock.lockA.Lock() mock.calls.A = nil mock.lockA.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go index d173753d..9e3dce15 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Expecter is a mock implementation of Expecter. +// ExpecterMock is a mock implementation of Expecter. // // func TestSomethingThatUsesExpecter(t *testing.T) { // // // make and configure a mocked Expecter -// mockedExpecter := &Expecter{ +// mockedExpecter := &ExpecterMock{ // ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { // panic("mock out the ManyArgsReturns method") // }, @@ -34,7 +34,7 @@ import ( // // and then make assertions. // // } -type Expecter struct { +type ExpecterMock struct { // ManyArgsReturnsFunc mocks the ManyArgsReturns method. ManyArgsReturnsFunc func(str string, i int) ([]string, error) @@ -90,9 +90,9 @@ type Expecter struct { } // ManyArgsReturns calls ManyArgsReturnsFunc. -func (mock *Expecter) ManyArgsReturns(str string, i int) ([]string, error) { +func (mock *ExpecterMock) ManyArgsReturns(str string, i int) ([]string, error) { if mock.ManyArgsReturnsFunc == nil { - panic("Expecter.ManyArgsReturnsFunc: method is nil but Expecter.ManyArgsReturns was just called") + panic("ExpecterMock.ManyArgsReturnsFunc: method is nil but Expecter.ManyArgsReturns was just called") } callInfo := struct { Str string @@ -111,7 +111,7 @@ func (mock *Expecter) ManyArgsReturns(str string, i int) ([]string, error) { // Check the length with: // // len(mockedExpecter.ManyArgsReturnsCalls()) -func (mock *Expecter) ManyArgsReturnsCalls() []struct { +func (mock *ExpecterMock) ManyArgsReturnsCalls() []struct { Str string I int } { @@ -126,16 +126,16 @@ func (mock *Expecter) ManyArgsReturnsCalls() []struct { } // ResetManyArgsReturnsCalls reset all the calls that were made to ManyArgsReturns. -func (mock *Expecter) ResetManyArgsReturnsCalls() { +func (mock *ExpecterMock) ResetManyArgsReturnsCalls() { mock.lockManyArgsReturns.Lock() mock.calls.ManyArgsReturns = nil mock.lockManyArgsReturns.Unlock() } // NoArg calls NoArgFunc. -func (mock *Expecter) NoArg() string { +func (mock *ExpecterMock) NoArg() string { if mock.NoArgFunc == nil { - panic("Expecter.NoArgFunc: method is nil but Expecter.NoArg was just called") + panic("ExpecterMock.NoArgFunc: method is nil but Expecter.NoArg was just called") } callInfo := struct { }{} @@ -149,7 +149,7 @@ func (mock *Expecter) NoArg() string { // Check the length with: // // len(mockedExpecter.NoArgCalls()) -func (mock *Expecter) NoArgCalls() []struct { +func (mock *ExpecterMock) NoArgCalls() []struct { } { var calls []struct { } @@ -160,16 +160,16 @@ func (mock *Expecter) NoArgCalls() []struct { } // ResetNoArgCalls reset all the calls that were made to NoArg. -func (mock *Expecter) ResetNoArgCalls() { +func (mock *ExpecterMock) ResetNoArgCalls() { mock.lockNoArg.Lock() mock.calls.NoArg = nil mock.lockNoArg.Unlock() } // NoReturn calls NoReturnFunc. -func (mock *Expecter) NoReturn(str string) { +func (mock *ExpecterMock) NoReturn(str string) { if mock.NoReturnFunc == nil { - panic("Expecter.NoReturnFunc: method is nil but Expecter.NoReturn was just called") + panic("ExpecterMock.NoReturnFunc: method is nil but Expecter.NoReturn was just called") } callInfo := struct { Str string @@ -186,7 +186,7 @@ func (mock *Expecter) NoReturn(str string) { // Check the length with: // // len(mockedExpecter.NoReturnCalls()) -func (mock *Expecter) NoReturnCalls() []struct { +func (mock *ExpecterMock) NoReturnCalls() []struct { Str string } { var calls []struct { @@ -199,16 +199,16 @@ func (mock *Expecter) NoReturnCalls() []struct { } // ResetNoReturnCalls reset all the calls that were made to NoReturn. -func (mock *Expecter) ResetNoReturnCalls() { +func (mock *ExpecterMock) ResetNoReturnCalls() { mock.lockNoReturn.Lock() mock.calls.NoReturn = nil mock.lockNoReturn.Unlock() } // Variadic calls VariadicFunc. -func (mock *Expecter) Variadic(ints ...int) error { +func (mock *ExpecterMock) Variadic(ints ...int) error { if mock.VariadicFunc == nil { - panic("Expecter.VariadicFunc: method is nil but Expecter.Variadic was just called") + panic("ExpecterMock.VariadicFunc: method is nil but Expecter.Variadic was just called") } callInfo := struct { Ints []int @@ -225,7 +225,7 @@ func (mock *Expecter) Variadic(ints ...int) error { // Check the length with: // // len(mockedExpecter.VariadicCalls()) -func (mock *Expecter) VariadicCalls() []struct { +func (mock *ExpecterMock) VariadicCalls() []struct { Ints []int } { var calls []struct { @@ -238,16 +238,16 @@ func (mock *Expecter) VariadicCalls() []struct { } // ResetVariadicCalls reset all the calls that were made to Variadic. -func (mock *Expecter) ResetVariadicCalls() { +func (mock *ExpecterMock) ResetVariadicCalls() { mock.lockVariadic.Lock() mock.calls.Variadic = nil mock.lockVariadic.Unlock() } // VariadicMany calls VariadicManyFunc. -func (mock *Expecter) VariadicMany(i int, a string, intfs ...interface{}) error { +func (mock *ExpecterMock) VariadicMany(i int, a string, intfs ...interface{}) error { if mock.VariadicManyFunc == nil { - panic("Expecter.VariadicManyFunc: method is nil but Expecter.VariadicMany was just called") + panic("ExpecterMock.VariadicManyFunc: method is nil but Expecter.VariadicMany was just called") } callInfo := struct { I int @@ -268,7 +268,7 @@ func (mock *Expecter) VariadicMany(i int, a string, intfs ...interface{}) error // Check the length with: // // len(mockedExpecter.VariadicManyCalls()) -func (mock *Expecter) VariadicManyCalls() []struct { +func (mock *ExpecterMock) VariadicManyCalls() []struct { I int A string Intfs []interface{} @@ -285,14 +285,14 @@ func (mock *Expecter) VariadicManyCalls() []struct { } // ResetVariadicManyCalls reset all the calls that were made to VariadicMany. -func (mock *Expecter) ResetVariadicManyCalls() { +func (mock *ExpecterMock) ResetVariadicManyCalls() { mock.lockVariadicMany.Lock() mock.calls.VariadicMany = nil mock.lockVariadicMany.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Expecter) ResetCalls() { +func (mock *ExpecterMock) ResetCalls() { mock.lockManyArgsReturns.Lock() mock.calls.ManyArgsReturns = nil mock.lockManyArgsReturns.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go index fd07804b..1e5915bd 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Fooer is a mock implementation of Fooer. +// FooerMock is a mock implementation of Fooer. // // func TestSomethingThatUsesFooer(t *testing.T) { // // // make and configure a mocked Fooer -// mockedFooer := &Fooer{ +// mockedFooer := &FooerMock{ // BarFunc: func(f func([]int)) { // panic("mock out the Bar method") // }, @@ -28,7 +28,7 @@ import ( // // and then make assertions. // // } -type Fooer struct { +type FooerMock struct { // BarFunc mocks the Bar method. BarFunc func(f func([]int)) @@ -62,9 +62,9 @@ type Fooer struct { } // Bar calls BarFunc. -func (mock *Fooer) Bar(f func([]int)) { +func (mock *FooerMock) Bar(f func([]int)) { if mock.BarFunc == nil { - panic("Fooer.BarFunc: method is nil but Fooer.Bar was just called") + panic("FooerMock.BarFunc: method is nil but Fooer.Bar was just called") } callInfo := struct { F func([]int) @@ -81,7 +81,7 @@ func (mock *Fooer) Bar(f func([]int)) { // Check the length with: // // len(mockedFooer.BarCalls()) -func (mock *Fooer) BarCalls() []struct { +func (mock *FooerMock) BarCalls() []struct { F func([]int) } { var calls []struct { @@ -94,16 +94,16 @@ func (mock *Fooer) BarCalls() []struct { } // ResetBarCalls reset all the calls that were made to Bar. -func (mock *Fooer) ResetBarCalls() { +func (mock *FooerMock) ResetBarCalls() { mock.lockBar.Lock() mock.calls.Bar = nil mock.lockBar.Unlock() } // Baz calls BazFunc. -func (mock *Fooer) Baz(path string) func(x string) string { +func (mock *FooerMock) Baz(path string) func(x string) string { if mock.BazFunc == nil { - panic("Fooer.BazFunc: method is nil but Fooer.Baz was just called") + panic("FooerMock.BazFunc: method is nil but Fooer.Baz was just called") } callInfo := struct { Path string @@ -120,7 +120,7 @@ func (mock *Fooer) Baz(path string) func(x string) string { // Check the length with: // // len(mockedFooer.BazCalls()) -func (mock *Fooer) BazCalls() []struct { +func (mock *FooerMock) BazCalls() []struct { Path string } { var calls []struct { @@ -133,16 +133,16 @@ func (mock *Fooer) BazCalls() []struct { } // ResetBazCalls reset all the calls that were made to Baz. -func (mock *Fooer) ResetBazCalls() { +func (mock *FooerMock) ResetBazCalls() { mock.lockBaz.Lock() mock.calls.Baz = nil mock.lockBaz.Unlock() } // Foo calls FooFunc. -func (mock *Fooer) Foo(f func(x string) string) error { +func (mock *FooerMock) Foo(f func(x string) string) error { if mock.FooFunc == nil { - panic("Fooer.FooFunc: method is nil but Fooer.Foo was just called") + panic("FooerMock.FooFunc: method is nil but Fooer.Foo was just called") } callInfo := struct { F func(x string) string @@ -159,7 +159,7 @@ func (mock *Fooer) Foo(f func(x string) string) error { // Check the length with: // // len(mockedFooer.FooCalls()) -func (mock *Fooer) FooCalls() []struct { +func (mock *FooerMock) FooCalls() []struct { F func(x string) string } { var calls []struct { @@ -172,14 +172,14 @@ func (mock *Fooer) FooCalls() []struct { } // ResetFooCalls reset all the calls that were made to Foo. -func (mock *Fooer) ResetFooCalls() { +func (mock *FooerMock) ResetFooCalls() { mock.lockFoo.Lock() mock.calls.Foo = nil mock.lockFoo.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Fooer) ResetCalls() { +func (mock *FooerMock) ResetCalls() { mock.lockBar.Lock() mock.calls.Bar = nil mock.lockBar.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go index b6010f76..8b158e73 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go @@ -7,12 +7,12 @@ import ( "sync" ) -// FuncArgsCollision is a mock implementation of FuncArgsCollision. +// FuncArgsCollisionMock is a mock implementation of FuncArgsCollision. // // func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { // // // make and configure a mocked FuncArgsCollision -// mockedFuncArgsCollision := &FuncArgsCollision{ +// mockedFuncArgsCollision := &FuncArgsCollisionMock{ // FooFunc: func(ret interface{}) error { // panic("mock out the Foo method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type FuncArgsCollision struct { +type FuncArgsCollisionMock struct { // FooFunc mocks the Foo method. FooFunc func(ret interface{}) error @@ -38,9 +38,9 @@ type FuncArgsCollision struct { } // Foo calls FooFunc. -func (mock *FuncArgsCollision) Foo(ret interface{}) error { +func (mock *FuncArgsCollisionMock) Foo(ret interface{}) error { if mock.FooFunc == nil { - panic("FuncArgsCollision.FooFunc: method is nil but FuncArgsCollision.Foo was just called") + panic("FuncArgsCollisionMock.FooFunc: method is nil but FuncArgsCollision.Foo was just called") } callInfo := struct { Ret interface{} @@ -57,7 +57,7 @@ func (mock *FuncArgsCollision) Foo(ret interface{}) error { // Check the length with: // // len(mockedFuncArgsCollision.FooCalls()) -func (mock *FuncArgsCollision) FooCalls() []struct { +func (mock *FuncArgsCollisionMock) FooCalls() []struct { Ret interface{} } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *FuncArgsCollision) FooCalls() []struct { } // ResetFooCalls reset all the calls that were made to Foo. -func (mock *FuncArgsCollision) ResetFooCalls() { +func (mock *FuncArgsCollisionMock) ResetFooCalls() { mock.lockFoo.Lock() mock.calls.Foo = nil mock.lockFoo.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *FuncArgsCollision) ResetCalls() { +func (mock *FuncArgsCollisionMock) ResetCalls() { mock.lockFoo.Lock() mock.calls.Foo = nil mock.lockFoo.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go index 00330f51..8c44f575 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go @@ -9,12 +9,12 @@ import ( "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// GetGeneric is a mock implementation of GetGeneric. +// GetGenericMock is a mock implementation of GetGeneric. // // func TestSomethingThatUsesGetGeneric(t *testing.T) { // // // make and configure a mocked GetGeneric -// mockedGetGeneric := &GetGeneric{ +// mockedGetGeneric := &GetGenericMock{ // GetFunc: func() T { // panic("mock out the Get method") // }, @@ -24,7 +24,7 @@ import ( // // and then make assertions. // // } -type GetGeneric[T constraints.Integer] struct { +type GetGenericMock[T constraints.Integer] struct { // GetFunc mocks the Get method. GetFunc func() T @@ -38,9 +38,9 @@ type GetGeneric[T constraints.Integer] struct { } // Get calls GetFunc. -func (mock *GetGeneric[T]) Get() T { +func (mock *GetGenericMock[T]) Get() T { if mock.GetFunc == nil { - panic("GetGeneric.GetFunc: method is nil but GetGeneric.Get was just called") + panic("GetGenericMock.GetFunc: method is nil but GetGeneric.Get was just called") } callInfo := struct { }{} @@ -54,7 +54,7 @@ func (mock *GetGeneric[T]) Get() T { // Check the length with: // // len(mockedGetGeneric.GetCalls()) -func (mock *GetGeneric[T]) GetCalls() []struct { +func (mock *GetGenericMock[T]) GetCalls() []struct { } { var calls []struct { } @@ -65,14 +65,14 @@ func (mock *GetGeneric[T]) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *GetGeneric[T]) ResetGetCalls() { +func (mock *GetGenericMock[T]) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *GetGeneric[T]) ResetCalls() { +func (mock *GetGenericMock[T]) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go index bfa3335f..ade38a64 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go @@ -7,12 +7,12 @@ import ( "sync" ) -// GetInt is a mock implementation of GetInt. +// GetIntMock is a mock implementation of GetInt. // // func TestSomethingThatUsesGetInt(t *testing.T) { // // // make and configure a mocked GetInt -// mockedGetInt := &GetInt{ +// mockedGetInt := &GetIntMock{ // GetFunc: func() int { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type GetInt struct { +type GetIntMock struct { // GetFunc mocks the Get method. GetFunc func() int @@ -36,9 +36,9 @@ type GetInt struct { } // Get calls GetFunc. -func (mock *GetInt) Get() int { +func (mock *GetIntMock) Get() int { if mock.GetFunc == nil { - panic("GetInt.GetFunc: method is nil but GetInt.Get was just called") + panic("GetIntMock.GetFunc: method is nil but GetInt.Get was just called") } callInfo := struct { }{} @@ -52,7 +52,7 @@ func (mock *GetInt) Get() int { // Check the length with: // // len(mockedGetInt.GetCalls()) -func (mock *GetInt) GetCalls() []struct { +func (mock *GetIntMock) GetCalls() []struct { } { var calls []struct { } @@ -63,14 +63,14 @@ func (mock *GetInt) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *GetInt) ResetGetCalls() { +func (mock *GetIntMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *GetInt) ResetCalls() { +func (mock *GetIntMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go index b6212212..de0a208a 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go @@ -10,12 +10,12 @@ import ( my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// HasConflictingNestedImports is a mock implementation of HasConflictingNestedImports. +// HasConflictingNestedImportsMock is a mock implementation of HasConflictingNestedImports. // // func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { // // // make and configure a mocked HasConflictingNestedImports -// mockedHasConflictingNestedImports := &HasConflictingNestedImports{ +// mockedHasConflictingNestedImports := &HasConflictingNestedImportsMock{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") // }, @@ -28,7 +28,7 @@ import ( // // and then make assertions. // // } -type HasConflictingNestedImports struct { +type HasConflictingNestedImportsMock struct { // GetFunc mocks the Get method. GetFunc func(path string) (http.Response, error) @@ -51,9 +51,9 @@ type HasConflictingNestedImports struct { } // Get calls GetFunc. -func (mock *HasConflictingNestedImports) Get(path string) (http.Response, error) { +func (mock *HasConflictingNestedImportsMock) Get(path string) (http.Response, error) { if mock.GetFunc == nil { - panic("HasConflictingNestedImports.GetFunc: method is nil but HasConflictingNestedImports.Get was just called") + panic("HasConflictingNestedImportsMock.GetFunc: method is nil but HasConflictingNestedImports.Get was just called") } callInfo := struct { Path string @@ -70,7 +70,7 @@ func (mock *HasConflictingNestedImports) Get(path string) (http.Response, error) // Check the length with: // // len(mockedHasConflictingNestedImports.GetCalls()) -func (mock *HasConflictingNestedImports) GetCalls() []struct { +func (mock *HasConflictingNestedImportsMock) GetCalls() []struct { Path string } { var calls []struct { @@ -83,16 +83,16 @@ func (mock *HasConflictingNestedImports) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *HasConflictingNestedImports) ResetGetCalls() { +func (mock *HasConflictingNestedImportsMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // Z calls ZFunc. -func (mock *HasConflictingNestedImports) Z() my_http.MyStruct { +func (mock *HasConflictingNestedImportsMock) Z() my_http.MyStruct { if mock.ZFunc == nil { - panic("HasConflictingNestedImports.ZFunc: method is nil but HasConflictingNestedImports.Z was just called") + panic("HasConflictingNestedImportsMock.ZFunc: method is nil but HasConflictingNestedImports.Z was just called") } callInfo := struct { }{} @@ -106,7 +106,7 @@ func (mock *HasConflictingNestedImports) Z() my_http.MyStruct { // Check the length with: // // len(mockedHasConflictingNestedImports.ZCalls()) -func (mock *HasConflictingNestedImports) ZCalls() []struct { +func (mock *HasConflictingNestedImportsMock) ZCalls() []struct { } { var calls []struct { } @@ -117,14 +117,14 @@ func (mock *HasConflictingNestedImports) ZCalls() []struct { } // ResetZCalls reset all the calls that were made to Z. -func (mock *HasConflictingNestedImports) ResetZCalls() { +func (mock *HasConflictingNestedImportsMock) ResetZCalls() { mock.lockZ.Lock() mock.calls.Z = nil mock.lockZ.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *HasConflictingNestedImports) ResetCalls() { +func (mock *HasConflictingNestedImportsMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go index 589ae3f7..3774be2f 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go @@ -10,12 +10,12 @@ import ( redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" ) -// ImportsSameAsPackage is a mock implementation of ImportsSameAsPackage. +// ImportsSameAsPackageMock is a mock implementation of ImportsSameAsPackage. // // func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { // // // make and configure a mocked ImportsSameAsPackage -// mockedImportsSameAsPackage := &ImportsSameAsPackage{ +// mockedImportsSameAsPackage := &ImportsSameAsPackageMock{ // AFunc: func() redefinedtypeb.B { // panic("mock out the A method") // }, @@ -31,7 +31,7 @@ import ( // // and then make assertions. // // } -type ImportsSameAsPackage struct { +type ImportsSameAsPackageMock struct { // AFunc mocks the A method. AFunc func() redefinedtypeb.B @@ -61,9 +61,9 @@ type ImportsSameAsPackage struct { } // A calls AFunc. -func (mock *ImportsSameAsPackage) A() redefinedtypeb.B { +func (mock *ImportsSameAsPackageMock) A() redefinedtypeb.B { if mock.AFunc == nil { - panic("ImportsSameAsPackage.AFunc: method is nil but ImportsSameAsPackage.A was just called") + panic("ImportsSameAsPackageMock.AFunc: method is nil but ImportsSameAsPackage.A was just called") } callInfo := struct { }{} @@ -77,7 +77,7 @@ func (mock *ImportsSameAsPackage) A() redefinedtypeb.B { // Check the length with: // // len(mockedImportsSameAsPackage.ACalls()) -func (mock *ImportsSameAsPackage) ACalls() []struct { +func (mock *ImportsSameAsPackageMock) ACalls() []struct { } { var calls []struct { } @@ -88,16 +88,16 @@ func (mock *ImportsSameAsPackage) ACalls() []struct { } // ResetACalls reset all the calls that were made to A. -func (mock *ImportsSameAsPackage) ResetACalls() { +func (mock *ImportsSameAsPackageMock) ResetACalls() { mock.lockA.Lock() mock.calls.A = nil mock.lockA.Unlock() } // B calls BFunc. -func (mock *ImportsSameAsPackage) B() fixtures.KeyManager { +func (mock *ImportsSameAsPackageMock) B() fixtures.KeyManager { if mock.BFunc == nil { - panic("ImportsSameAsPackage.BFunc: method is nil but ImportsSameAsPackage.B was just called") + panic("ImportsSameAsPackageMock.BFunc: method is nil but ImportsSameAsPackage.B was just called") } callInfo := struct { }{} @@ -111,7 +111,7 @@ func (mock *ImportsSameAsPackage) B() fixtures.KeyManager { // Check the length with: // // len(mockedImportsSameAsPackage.BCalls()) -func (mock *ImportsSameAsPackage) BCalls() []struct { +func (mock *ImportsSameAsPackageMock) BCalls() []struct { } { var calls []struct { } @@ -122,16 +122,16 @@ func (mock *ImportsSameAsPackage) BCalls() []struct { } // ResetBCalls reset all the calls that were made to B. -func (mock *ImportsSameAsPackage) ResetBCalls() { +func (mock *ImportsSameAsPackageMock) ResetBCalls() { mock.lockB.Lock() mock.calls.B = nil mock.lockB.Unlock() } // C calls CFunc. -func (mock *ImportsSameAsPackage) C(c fixtures.C) { +func (mock *ImportsSameAsPackageMock) C(c fixtures.C) { if mock.CFunc == nil { - panic("ImportsSameAsPackage.CFunc: method is nil but ImportsSameAsPackage.C was just called") + panic("ImportsSameAsPackageMock.CFunc: method is nil but ImportsSameAsPackage.C was just called") } callInfo := struct { C fixtures.C @@ -148,7 +148,7 @@ func (mock *ImportsSameAsPackage) C(c fixtures.C) { // Check the length with: // // len(mockedImportsSameAsPackage.CCalls()) -func (mock *ImportsSameAsPackage) CCalls() []struct { +func (mock *ImportsSameAsPackageMock) CCalls() []struct { C fixtures.C } { var calls []struct { @@ -161,14 +161,14 @@ func (mock *ImportsSameAsPackage) CCalls() []struct { } // ResetCCalls reset all the calls that were made to C. -func (mock *ImportsSameAsPackage) ResetCCalls() { +func (mock *ImportsSameAsPackageMock) ResetCCalls() { mock.lockC.Lock() mock.calls.C = nil mock.lockC.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ImportsSameAsPackage) ResetCalls() { +func (mock *ImportsSameAsPackageMock) ResetCalls() { mock.lockA.Lock() mock.calls.A = nil mock.lockA.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go index f152a015..48da412f 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go @@ -9,12 +9,12 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// KeyManager is a mock implementation of KeyManager. +// KeyManagerMock is a mock implementation of KeyManager. // // func TestSomethingThatUsesKeyManager(t *testing.T) { // // // make and configure a mocked KeyManager -// mockedKeyManager := &KeyManager{ +// mockedKeyManager := &KeyManagerMock{ // GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { // panic("mock out the GetKey method") // }, @@ -24,7 +24,7 @@ import ( // // and then make assertions. // // } -type KeyManager struct { +type KeyManagerMock struct { // GetKeyFunc mocks the GetKey method. GetKeyFunc func(s string, v uint16) ([]byte, *test.Err) @@ -42,9 +42,9 @@ type KeyManager struct { } // GetKey calls GetKeyFunc. -func (mock *KeyManager) GetKey(s string, v uint16) ([]byte, *test.Err) { +func (mock *KeyManagerMock) GetKey(s string, v uint16) ([]byte, *test.Err) { if mock.GetKeyFunc == nil { - panic("KeyManager.GetKeyFunc: method is nil but KeyManager.GetKey was just called") + panic("KeyManagerMock.GetKeyFunc: method is nil but KeyManager.GetKey was just called") } callInfo := struct { S string @@ -63,7 +63,7 @@ func (mock *KeyManager) GetKey(s string, v uint16) ([]byte, *test.Err) { // Check the length with: // // len(mockedKeyManager.GetKeyCalls()) -func (mock *KeyManager) GetKeyCalls() []struct { +func (mock *KeyManagerMock) GetKeyCalls() []struct { S string V uint16 } { @@ -78,14 +78,14 @@ func (mock *KeyManager) GetKeyCalls() []struct { } // ResetGetKeyCalls reset all the calls that were made to GetKey. -func (mock *KeyManager) ResetGetKeyCalls() { +func (mock *KeyManagerMock) ResetGetKeyCalls() { mock.lockGetKey.Lock() mock.calls.GetKey = nil mock.lockGetKey.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *KeyManager) ResetCalls() { +func (mock *KeyManagerMock) ResetCalls() { mock.lockGetKey.Lock() mock.calls.GetKey = nil mock.lockGetKey.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go index 36c9cc88..5924049b 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go @@ -7,12 +7,12 @@ import ( "sync" ) -// MapFunc is a mock implementation of MapFunc. +// MapFuncMock is a mock implementation of MapFunc. // // func TestSomethingThatUsesMapFunc(t *testing.T) { // // // make and configure a mocked MapFunc -// mockedMapFunc := &MapFunc{ +// mockedMapFunc := &MapFuncMock{ // GetFunc: func(m map[string]func(string) string) error { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type MapFunc struct { +type MapFuncMock struct { // GetFunc mocks the Get method. GetFunc func(m map[string]func(string) string) error @@ -38,9 +38,9 @@ type MapFunc struct { } // Get calls GetFunc. -func (mock *MapFunc) Get(m map[string]func(string) string) error { +func (mock *MapFuncMock) Get(m map[string]func(string) string) error { if mock.GetFunc == nil { - panic("MapFunc.GetFunc: method is nil but MapFunc.Get was just called") + panic("MapFuncMock.GetFunc: method is nil but MapFunc.Get was just called") } callInfo := struct { M map[string]func(string) string @@ -57,7 +57,7 @@ func (mock *MapFunc) Get(m map[string]func(string) string) error { // Check the length with: // // len(mockedMapFunc.GetCalls()) -func (mock *MapFunc) GetCalls() []struct { +func (mock *MapFuncMock) GetCalls() []struct { M map[string]func(string) string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *MapFunc) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *MapFunc) ResetGetCalls() { +func (mock *MapFuncMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MapFunc) ResetCalls() { +func (mock *MapFuncMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go index 8edc6b7c..32809307 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go @@ -7,12 +7,12 @@ import ( "sync" ) -// MapToInterface is a mock implementation of MapToInterface. +// MapToInterfaceMock is a mock implementation of MapToInterface. // // func TestSomethingThatUsesMapToInterface(t *testing.T) { // // // make and configure a mocked MapToInterface -// mockedMapToInterface := &MapToInterface{ +// mockedMapToInterface := &MapToInterfaceMock{ // FooFunc: func(arg1 ...map[string]interface{}) { // panic("mock out the Foo method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type MapToInterface struct { +type MapToInterfaceMock struct { // FooFunc mocks the Foo method. FooFunc func(arg1 ...map[string]interface{}) @@ -38,9 +38,9 @@ type MapToInterface struct { } // Foo calls FooFunc. -func (mock *MapToInterface) Foo(arg1 ...map[string]interface{}) { +func (mock *MapToInterfaceMock) Foo(arg1 ...map[string]interface{}) { if mock.FooFunc == nil { - panic("MapToInterface.FooFunc: method is nil but MapToInterface.Foo was just called") + panic("MapToInterfaceMock.FooFunc: method is nil but MapToInterface.Foo was just called") } callInfo := struct { Arg1 []map[string]interface{} @@ -57,7 +57,7 @@ func (mock *MapToInterface) Foo(arg1 ...map[string]interface{}) { // Check the length with: // // len(mockedMapToInterface.FooCalls()) -func (mock *MapToInterface) FooCalls() []struct { +func (mock *MapToInterfaceMock) FooCalls() []struct { Arg1 []map[string]interface{} } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *MapToInterface) FooCalls() []struct { } // ResetFooCalls reset all the calls that were made to Foo. -func (mock *MapToInterface) ResetFooCalls() { +func (mock *MapToInterfaceMock) ResetFooCalls() { mock.lockFoo.Lock() mock.calls.Foo = nil mock.lockFoo.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MapToInterface) ResetCalls() { +func (mock *MapToInterfaceMock) ResetCalls() { mock.lockFoo.Lock() mock.calls.Foo = nil mock.lockFoo.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go index c6236a74..d09592b2 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go @@ -7,12 +7,12 @@ import ( "sync" ) -// MyReader is a mock implementation of MyReader. +// MyReaderMock is a mock implementation of MyReader. // // func TestSomethingThatUsesMyReader(t *testing.T) { // // // make and configure a mocked MyReader -// mockedMyReader := &MyReader{ +// mockedMyReader := &MyReaderMock{ // ReadFunc: func(p []byte) (int, error) { // panic("mock out the Read method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type MyReader struct { +type MyReaderMock struct { // ReadFunc mocks the Read method. ReadFunc func(p []byte) (int, error) @@ -38,9 +38,9 @@ type MyReader struct { } // Read calls ReadFunc. -func (mock *MyReader) Read(p []byte) (int, error) { +func (mock *MyReaderMock) Read(p []byte) (int, error) { if mock.ReadFunc == nil { - panic("MyReader.ReadFunc: method is nil but MyReader.Read was just called") + panic("MyReaderMock.ReadFunc: method is nil but MyReader.Read was just called") } callInfo := struct { P []byte @@ -57,7 +57,7 @@ func (mock *MyReader) Read(p []byte) (int, error) { // Check the length with: // // len(mockedMyReader.ReadCalls()) -func (mock *MyReader) ReadCalls() []struct { +func (mock *MyReaderMock) ReadCalls() []struct { P []byte } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *MyReader) ReadCalls() []struct { } // ResetReadCalls reset all the calls that were made to Read. -func (mock *MyReader) ResetReadCalls() { +func (mock *MyReaderMock) ResetReadCalls() { mock.lockRead.Lock() mock.calls.Read = nil mock.lockRead.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MyReader) ResetCalls() { +func (mock *MyReaderMock) ResetCalls() { mock.lockRead.Lock() mock.calls.Read = nil mock.lockRead.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go index a8f88660..950b1e09 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go @@ -7,12 +7,12 @@ import ( "sync" ) -// PanicOnNoReturnValue is a mock implementation of PanicOnNoReturnValue. +// PanicOnNoReturnValueMock is a mock implementation of PanicOnNoReturnValue. // // func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { // // // make and configure a mocked PanicOnNoReturnValue -// mockedPanicOnNoReturnValue := &PanicOnNoReturnValue{ +// mockedPanicOnNoReturnValue := &PanicOnNoReturnValueMock{ // DoSomethingFunc: func() string { // panic("mock out the DoSomething method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type PanicOnNoReturnValue struct { +type PanicOnNoReturnValueMock struct { // DoSomethingFunc mocks the DoSomething method. DoSomethingFunc func() string @@ -36,9 +36,9 @@ type PanicOnNoReturnValue struct { } // DoSomething calls DoSomethingFunc. -func (mock *PanicOnNoReturnValue) DoSomething() string { +func (mock *PanicOnNoReturnValueMock) DoSomething() string { if mock.DoSomethingFunc == nil { - panic("PanicOnNoReturnValue.DoSomethingFunc: method is nil but PanicOnNoReturnValue.DoSomething was just called") + panic("PanicOnNoReturnValueMock.DoSomethingFunc: method is nil but PanicOnNoReturnValue.DoSomething was just called") } callInfo := struct { }{} @@ -52,7 +52,7 @@ func (mock *PanicOnNoReturnValue) DoSomething() string { // Check the length with: // // len(mockedPanicOnNoReturnValue.DoSomethingCalls()) -func (mock *PanicOnNoReturnValue) DoSomethingCalls() []struct { +func (mock *PanicOnNoReturnValueMock) DoSomethingCalls() []struct { } { var calls []struct { } @@ -63,14 +63,14 @@ func (mock *PanicOnNoReturnValue) DoSomethingCalls() []struct { } // ResetDoSomethingCalls reset all the calls that were made to DoSomething. -func (mock *PanicOnNoReturnValue) ResetDoSomethingCalls() { +func (mock *PanicOnNoReturnValueMock) ResetDoSomethingCalls() { mock.lockDoSomething.Lock() mock.calls.DoSomething = nil mock.lockDoSomething.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *PanicOnNoReturnValue) ResetCalls() { +func (mock *PanicOnNoReturnValueMock) ResetCalls() { mock.lockDoSomething.Lock() mock.calls.DoSomething = nil mock.lockDoSomething.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go index 1c4649c6..bf455bdc 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Requester is a mock implementation of Requester. +// RequesterMock is a mock implementation of Requester. // // func TestSomethingThatUsesRequester(t *testing.T) { // // // make and configure a mocked Requester -// mockedRequester := &Requester{ +// mockedRequester := &RequesterMock{ // GetFunc: func(path string) (string, error) { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Requester struct { +type RequesterMock struct { // GetFunc mocks the Get method. GetFunc func(path string) (string, error) @@ -38,9 +38,9 @@ type Requester struct { } // Get calls GetFunc. -func (mock *Requester) Get(path string) (string, error) { +func (mock *RequesterMock) Get(path string) (string, error) { if mock.GetFunc == nil { - panic("Requester.GetFunc: method is nil but Requester.Get was just called") + panic("RequesterMock.GetFunc: method is nil but Requester.Get was just called") } callInfo := struct { Path string @@ -57,7 +57,7 @@ func (mock *Requester) Get(path string) (string, error) { // Check the length with: // // len(mockedRequester.GetCalls()) -func (mock *Requester) GetCalls() []struct { +func (mock *RequesterMock) GetCalls() []struct { Path string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *Requester) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester) ResetGetCalls() { +func (mock *RequesterMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester) ResetCalls() { +func (mock *RequesterMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go index fffb00a9..3ee96f97 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Requester2 is a mock implementation of Requester2. +// Requester2Mock is a mock implementation of Requester2. // // func TestSomethingThatUsesRequester2(t *testing.T) { // // // make and configure a mocked Requester2 -// mockedRequester2 := &Requester2{ +// mockedRequester2 := &Requester2Mock{ // GetFunc: func(path string) error { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Requester2 struct { +type Requester2Mock struct { // GetFunc mocks the Get method. GetFunc func(path string) error @@ -38,9 +38,9 @@ type Requester2 struct { } // Get calls GetFunc. -func (mock *Requester2) Get(path string) error { +func (mock *Requester2Mock) Get(path string) error { if mock.GetFunc == nil { - panic("Requester2.GetFunc: method is nil but Requester2.Get was just called") + panic("Requester2Mock.GetFunc: method is nil but Requester2.Get was just called") } callInfo := struct { Path string @@ -57,7 +57,7 @@ func (mock *Requester2) Get(path string) error { // Check the length with: // // len(mockedRequester2.GetCalls()) -func (mock *Requester2) GetCalls() []struct { +func (mock *Requester2Mock) GetCalls() []struct { Path string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *Requester2) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester2) ResetGetCalls() { +func (mock *Requester2Mock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester2) ResetCalls() { +func (mock *Requester2Mock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go index f0ac545b..455ba86e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Requester3 is a mock implementation of Requester3. +// Requester3Mock is a mock implementation of Requester3. // // func TestSomethingThatUsesRequester3(t *testing.T) { // // // make and configure a mocked Requester3 -// mockedRequester3 := &Requester3{ +// mockedRequester3 := &Requester3Mock{ // GetFunc: func() error { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Requester3 struct { +type Requester3Mock struct { // GetFunc mocks the Get method. GetFunc func() error @@ -36,9 +36,9 @@ type Requester3 struct { } // Get calls GetFunc. -func (mock *Requester3) Get() error { +func (mock *Requester3Mock) Get() error { if mock.GetFunc == nil { - panic("Requester3.GetFunc: method is nil but Requester3.Get was just called") + panic("Requester3Mock.GetFunc: method is nil but Requester3.Get was just called") } callInfo := struct { }{} @@ -52,7 +52,7 @@ func (mock *Requester3) Get() error { // Check the length with: // // len(mockedRequester3.GetCalls()) -func (mock *Requester3) GetCalls() []struct { +func (mock *Requester3Mock) GetCalls() []struct { } { var calls []struct { } @@ -63,14 +63,14 @@ func (mock *Requester3) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester3) ResetGetCalls() { +func (mock *Requester3Mock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester3) ResetCalls() { +func (mock *Requester3Mock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go index 454bd3be..3e640319 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Requester4 is a mock implementation of Requester4. +// Requester4Mock is a mock implementation of Requester4. // // func TestSomethingThatUsesRequester4(t *testing.T) { // // // make and configure a mocked Requester4 -// mockedRequester4 := &Requester4{ +// mockedRequester4 := &Requester4Mock{ // GetFunc: func() { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Requester4 struct { +type Requester4Mock struct { // GetFunc mocks the Get method. GetFunc func() @@ -36,9 +36,9 @@ type Requester4 struct { } // Get calls GetFunc. -func (mock *Requester4) Get() { +func (mock *Requester4Mock) Get() { if mock.GetFunc == nil { - panic("Requester4.GetFunc: method is nil but Requester4.Get was just called") + panic("Requester4Mock.GetFunc: method is nil but Requester4.Get was just called") } callInfo := struct { }{} @@ -52,7 +52,7 @@ func (mock *Requester4) Get() { // Check the length with: // // len(mockedRequester4.GetCalls()) -func (mock *Requester4) GetCalls() []struct { +func (mock *Requester4Mock) GetCalls() []struct { } { var calls []struct { } @@ -63,14 +63,14 @@ func (mock *Requester4) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester4) ResetGetCalls() { +func (mock *Requester4Mock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester4) ResetCalls() { +func (mock *Requester4Mock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go index c2235f3e..900b6d0c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go @@ -8,12 +8,12 @@ import ( "sync" ) -// RequesterArgSameAsImport is a mock implementation of RequesterArgSameAsImport. +// RequesterArgSameAsImportMock is a mock implementation of RequesterArgSameAsImport. // // func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { // // // make and configure a mocked RequesterArgSameAsImport -// mockedRequesterArgSameAsImport := &RequesterArgSameAsImport{ +// mockedRequesterArgSameAsImport := &RequesterArgSameAsImportMock{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, @@ -23,7 +23,7 @@ import ( // // and then make assertions. // // } -type RequesterArgSameAsImport struct { +type RequesterArgSameAsImportMock struct { // GetFunc mocks the Get method. GetFunc func(jsonMoqParam string) *json.RawMessage @@ -39,9 +39,9 @@ type RequesterArgSameAsImport struct { } // Get calls GetFunc. -func (mock *RequesterArgSameAsImport) Get(jsonMoqParam string) *json.RawMessage { +func (mock *RequesterArgSameAsImportMock) Get(jsonMoqParam string) *json.RawMessage { if mock.GetFunc == nil { - panic("RequesterArgSameAsImport.GetFunc: method is nil but RequesterArgSameAsImport.Get was just called") + panic("RequesterArgSameAsImportMock.GetFunc: method is nil but RequesterArgSameAsImport.Get was just called") } callInfo := struct { JsonMoqParam string @@ -58,7 +58,7 @@ func (mock *RequesterArgSameAsImport) Get(jsonMoqParam string) *json.RawMessage // Check the length with: // // len(mockedRequesterArgSameAsImport.GetCalls()) -func (mock *RequesterArgSameAsImport) GetCalls() []struct { +func (mock *RequesterArgSameAsImportMock) GetCalls() []struct { JsonMoqParam string } { var calls []struct { @@ -71,14 +71,14 @@ func (mock *RequesterArgSameAsImport) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsImport) ResetGetCalls() { +func (mock *RequesterArgSameAsImportMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsImport) ResetCalls() { +func (mock *RequesterArgSameAsImportMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go index 55e53b19..fb3a41cb 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go @@ -8,12 +8,12 @@ import ( "sync" ) -// RequesterArgSameAsNamedImport is a mock implementation of RequesterArgSameAsNamedImport. +// RequesterArgSameAsNamedImportMock is a mock implementation of RequesterArgSameAsNamedImport. // // func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { // // // make and configure a mocked RequesterArgSameAsNamedImport -// mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImport{ +// mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImportMock{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, @@ -23,7 +23,7 @@ import ( // // and then make assertions. // // } -type RequesterArgSameAsNamedImport struct { +type RequesterArgSameAsNamedImportMock struct { // GetFunc mocks the Get method. GetFunc func(jsonMoqParam string) *json.RawMessage @@ -39,9 +39,9 @@ type RequesterArgSameAsNamedImport struct { } // Get calls GetFunc. -func (mock *RequesterArgSameAsNamedImport) Get(jsonMoqParam string) *json.RawMessage { +func (mock *RequesterArgSameAsNamedImportMock) Get(jsonMoqParam string) *json.RawMessage { if mock.GetFunc == nil { - panic("RequesterArgSameAsNamedImport.GetFunc: method is nil but RequesterArgSameAsNamedImport.Get was just called") + panic("RequesterArgSameAsNamedImportMock.GetFunc: method is nil but RequesterArgSameAsNamedImport.Get was just called") } callInfo := struct { JsonMoqParam string @@ -58,7 +58,7 @@ func (mock *RequesterArgSameAsNamedImport) Get(jsonMoqParam string) *json.RawMes // Check the length with: // // len(mockedRequesterArgSameAsNamedImport.GetCalls()) -func (mock *RequesterArgSameAsNamedImport) GetCalls() []struct { +func (mock *RequesterArgSameAsNamedImportMock) GetCalls() []struct { JsonMoqParam string } { var calls []struct { @@ -71,14 +71,14 @@ func (mock *RequesterArgSameAsNamedImport) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsNamedImport) ResetGetCalls() { +func (mock *RequesterArgSameAsNamedImportMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsNamedImport) ResetCalls() { +func (mock *RequesterArgSameAsNamedImportMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go index 9df55853..90736b41 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterArgSameAsPkg is a mock implementation of RequesterArgSameAsPkg. +// RequesterArgSameAsPkgMock is a mock implementation of RequesterArgSameAsPkg. // // func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { // // // make and configure a mocked RequesterArgSameAsPkg -// mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkg{ +// mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkgMock{ // GetFunc: func(test string) { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type RequesterArgSameAsPkg struct { +type RequesterArgSameAsPkgMock struct { // GetFunc mocks the Get method. GetFunc func(test string) @@ -38,9 +38,9 @@ type RequesterArgSameAsPkg struct { } // Get calls GetFunc. -func (mock *RequesterArgSameAsPkg) Get(test string) { +func (mock *RequesterArgSameAsPkgMock) Get(test string) { if mock.GetFunc == nil { - panic("RequesterArgSameAsPkg.GetFunc: method is nil but RequesterArgSameAsPkg.Get was just called") + panic("RequesterArgSameAsPkgMock.GetFunc: method is nil but RequesterArgSameAsPkg.Get was just called") } callInfo := struct { Test string @@ -57,7 +57,7 @@ func (mock *RequesterArgSameAsPkg) Get(test string) { // Check the length with: // // len(mockedRequesterArgSameAsPkg.GetCalls()) -func (mock *RequesterArgSameAsPkg) GetCalls() []struct { +func (mock *RequesterArgSameAsPkgMock) GetCalls() []struct { Test string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *RequesterArgSameAsPkg) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsPkg) ResetGetCalls() { +func (mock *RequesterArgSameAsPkgMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsPkg) ResetCalls() { +func (mock *RequesterArgSameAsPkgMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go index ce1ed103..30a646b2 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterArray is a mock implementation of RequesterArray. +// RequesterArrayMock is a mock implementation of RequesterArray. // // func TestSomethingThatUsesRequesterArray(t *testing.T) { // // // make and configure a mocked RequesterArray -// mockedRequesterArray := &RequesterArray{ +// mockedRequesterArray := &RequesterArrayMock{ // GetFunc: func(path string) ([2]string, error) { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type RequesterArray struct { +type RequesterArrayMock struct { // GetFunc mocks the Get method. GetFunc func(path string) ([2]string, error) @@ -38,9 +38,9 @@ type RequesterArray struct { } // Get calls GetFunc. -func (mock *RequesterArray) Get(path string) ([2]string, error) { +func (mock *RequesterArrayMock) Get(path string) ([2]string, error) { if mock.GetFunc == nil { - panic("RequesterArray.GetFunc: method is nil but RequesterArray.Get was just called") + panic("RequesterArrayMock.GetFunc: method is nil but RequesterArray.Get was just called") } callInfo := struct { Path string @@ -57,7 +57,7 @@ func (mock *RequesterArray) Get(path string) ([2]string, error) { // Check the length with: // // len(mockedRequesterArray.GetCalls()) -func (mock *RequesterArray) GetCalls() []struct { +func (mock *RequesterArrayMock) GetCalls() []struct { Path string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *RequesterArray) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArray) ResetGetCalls() { +func (mock *RequesterArrayMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArray) ResetCalls() { +func (mock *RequesterArrayMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go index adee512c..a48e5203 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterElided is a mock implementation of RequesterElided. +// RequesterElidedMock is a mock implementation of RequesterElided. // // func TestSomethingThatUsesRequesterElided(t *testing.T) { // // // make and configure a mocked RequesterElided -// mockedRequesterElided := &RequesterElided{ +// mockedRequesterElided := &RequesterElidedMock{ // GetFunc: func(path string, url string) error { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type RequesterElided struct { +type RequesterElidedMock struct { // GetFunc mocks the Get method. GetFunc func(path string, url string) error @@ -40,9 +40,9 @@ type RequesterElided struct { } // Get calls GetFunc. -func (mock *RequesterElided) Get(path string, url string) error { +func (mock *RequesterElidedMock) Get(path string, url string) error { if mock.GetFunc == nil { - panic("RequesterElided.GetFunc: method is nil but RequesterElided.Get was just called") + panic("RequesterElidedMock.GetFunc: method is nil but RequesterElided.Get was just called") } callInfo := struct { Path string @@ -61,7 +61,7 @@ func (mock *RequesterElided) Get(path string, url string) error { // Check the length with: // // len(mockedRequesterElided.GetCalls()) -func (mock *RequesterElided) GetCalls() []struct { +func (mock *RequesterElidedMock) GetCalls() []struct { Path string URL string } { @@ -76,14 +76,14 @@ func (mock *RequesterElided) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterElided) ResetGetCalls() { +func (mock *RequesterElidedMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterElided) ResetCalls() { +func (mock *RequesterElidedMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go index 2dd932a5..25298605 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go @@ -8,12 +8,12 @@ import ( "sync" ) -// RequesterIface is a mock implementation of RequesterIface. +// RequesterIfaceMock is a mock implementation of RequesterIface. // // func TestSomethingThatUsesRequesterIface(t *testing.T) { // // // make and configure a mocked RequesterIface -// mockedRequesterIface := &RequesterIface{ +// mockedRequesterIface := &RequesterIfaceMock{ // GetFunc: func() io.Reader { // panic("mock out the Get method") // }, @@ -23,7 +23,7 @@ import ( // // and then make assertions. // // } -type RequesterIface struct { +type RequesterIfaceMock struct { // GetFunc mocks the Get method. GetFunc func() io.Reader @@ -37,9 +37,9 @@ type RequesterIface struct { } // Get calls GetFunc. -func (mock *RequesterIface) Get() io.Reader { +func (mock *RequesterIfaceMock) Get() io.Reader { if mock.GetFunc == nil { - panic("RequesterIface.GetFunc: method is nil but RequesterIface.Get was just called") + panic("RequesterIfaceMock.GetFunc: method is nil but RequesterIface.Get was just called") } callInfo := struct { }{} @@ -53,7 +53,7 @@ func (mock *RequesterIface) Get() io.Reader { // Check the length with: // // len(mockedRequesterIface.GetCalls()) -func (mock *RequesterIface) GetCalls() []struct { +func (mock *RequesterIfaceMock) GetCalls() []struct { } { var calls []struct { } @@ -64,14 +64,14 @@ func (mock *RequesterIface) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterIface) ResetGetCalls() { +func (mock *RequesterIfaceMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterIface) ResetCalls() { +func (mock *RequesterIfaceMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go index 4002c815..91fd8112 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go @@ -8,12 +8,12 @@ import ( "sync" ) -// RequesterNS is a mock implementation of RequesterNS. +// RequesterNSMock is a mock implementation of RequesterNS. // // func TestSomethingThatUsesRequesterNS(t *testing.T) { // // // make and configure a mocked RequesterNS -// mockedRequesterNS := &RequesterNS{ +// mockedRequesterNS := &RequesterNSMock{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") // }, @@ -23,7 +23,7 @@ import ( // // and then make assertions. // // } -type RequesterNS struct { +type RequesterNSMock struct { // GetFunc mocks the Get method. GetFunc func(path string) (http.Response, error) @@ -39,9 +39,9 @@ type RequesterNS struct { } // Get calls GetFunc. -func (mock *RequesterNS) Get(path string) (http.Response, error) { +func (mock *RequesterNSMock) Get(path string) (http.Response, error) { if mock.GetFunc == nil { - panic("RequesterNS.GetFunc: method is nil but RequesterNS.Get was just called") + panic("RequesterNSMock.GetFunc: method is nil but RequesterNS.Get was just called") } callInfo := struct { Path string @@ -58,7 +58,7 @@ func (mock *RequesterNS) Get(path string) (http.Response, error) { // Check the length with: // // len(mockedRequesterNS.GetCalls()) -func (mock *RequesterNS) GetCalls() []struct { +func (mock *RequesterNSMock) GetCalls() []struct { Path string } { var calls []struct { @@ -71,14 +71,14 @@ func (mock *RequesterNS) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterNS) ResetGetCalls() { +func (mock *RequesterNSMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterNS) ResetCalls() { +func (mock *RequesterNSMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go index cec668a8..9a3f6031 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterPtr is a mock implementation of RequesterPtr. +// RequesterPtrMock is a mock implementation of RequesterPtr. // // func TestSomethingThatUsesRequesterPtr(t *testing.T) { // // // make and configure a mocked RequesterPtr -// mockedRequesterPtr := &RequesterPtr{ +// mockedRequesterPtr := &RequesterPtrMock{ // GetFunc: func(path string) (*string, error) { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type RequesterPtr struct { +type RequesterPtrMock struct { // GetFunc mocks the Get method. GetFunc func(path string) (*string, error) @@ -38,9 +38,9 @@ type RequesterPtr struct { } // Get calls GetFunc. -func (mock *RequesterPtr) Get(path string) (*string, error) { +func (mock *RequesterPtrMock) Get(path string) (*string, error) { if mock.GetFunc == nil { - panic("RequesterPtr.GetFunc: method is nil but RequesterPtr.Get was just called") + panic("RequesterPtrMock.GetFunc: method is nil but RequesterPtr.Get was just called") } callInfo := struct { Path string @@ -57,7 +57,7 @@ func (mock *RequesterPtr) Get(path string) (*string, error) { // Check the length with: // // len(mockedRequesterPtr.GetCalls()) -func (mock *RequesterPtr) GetCalls() []struct { +func (mock *RequesterPtrMock) GetCalls() []struct { Path string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *RequesterPtr) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterPtr) ResetGetCalls() { +func (mock *RequesterPtrMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterPtr) ResetCalls() { +func (mock *RequesterPtrMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go index 0f866093..ade8660d 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterReturnElided is a mock implementation of RequesterReturnElided. +// RequesterReturnElidedMock is a mock implementation of RequesterReturnElided. // // func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { // // // make and configure a mocked RequesterReturnElided -// mockedRequesterReturnElided := &RequesterReturnElided{ +// mockedRequesterReturnElided := &RequesterReturnElidedMock{ // GetFunc: func(path string) (int, int, int, error) { // panic("mock out the Get method") // }, @@ -25,7 +25,7 @@ import ( // // and then make assertions. // // } -type RequesterReturnElided struct { +type RequesterReturnElidedMock struct { // GetFunc mocks the Get method. GetFunc func(path string) (int, int, int, error) @@ -50,9 +50,9 @@ type RequesterReturnElided struct { } // Get calls GetFunc. -func (mock *RequesterReturnElided) Get(path string) (int, int, int, error) { +func (mock *RequesterReturnElidedMock) Get(path string) (int, int, int, error) { if mock.GetFunc == nil { - panic("RequesterReturnElided.GetFunc: method is nil but RequesterReturnElided.Get was just called") + panic("RequesterReturnElidedMock.GetFunc: method is nil but RequesterReturnElided.Get was just called") } callInfo := struct { Path string @@ -69,7 +69,7 @@ func (mock *RequesterReturnElided) Get(path string) (int, int, int, error) { // Check the length with: // // len(mockedRequesterReturnElided.GetCalls()) -func (mock *RequesterReturnElided) GetCalls() []struct { +func (mock *RequesterReturnElidedMock) GetCalls() []struct { Path string } { var calls []struct { @@ -82,16 +82,16 @@ func (mock *RequesterReturnElided) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterReturnElided) ResetGetCalls() { +func (mock *RequesterReturnElidedMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // Put calls PutFunc. -func (mock *RequesterReturnElided) Put(path string) (int, error) { +func (mock *RequesterReturnElidedMock) Put(path string) (int, error) { if mock.PutFunc == nil { - panic("RequesterReturnElided.PutFunc: method is nil but RequesterReturnElided.Put was just called") + panic("RequesterReturnElidedMock.PutFunc: method is nil but RequesterReturnElided.Put was just called") } callInfo := struct { Path string @@ -108,7 +108,7 @@ func (mock *RequesterReturnElided) Put(path string) (int, error) { // Check the length with: // // len(mockedRequesterReturnElided.PutCalls()) -func (mock *RequesterReturnElided) PutCalls() []struct { +func (mock *RequesterReturnElidedMock) PutCalls() []struct { Path string } { var calls []struct { @@ -121,14 +121,14 @@ func (mock *RequesterReturnElided) PutCalls() []struct { } // ResetPutCalls reset all the calls that were made to Put. -func (mock *RequesterReturnElided) ResetPutCalls() { +func (mock *RequesterReturnElidedMock) ResetPutCalls() { mock.lockPut.Lock() mock.calls.Put = nil mock.lockPut.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterReturnElided) ResetCalls() { +func (mock *RequesterReturnElidedMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go index 79902c6b..599e6ff1 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go @@ -7,12 +7,12 @@ import ( "sync" ) -// RequesterSlice is a mock implementation of RequesterSlice. +// RequesterSliceMock is a mock implementation of RequesterSlice. // // func TestSomethingThatUsesRequesterSlice(t *testing.T) { // // // make and configure a mocked RequesterSlice -// mockedRequesterSlice := &RequesterSlice{ +// mockedRequesterSlice := &RequesterSliceMock{ // GetFunc: func(path string) ([]string, error) { // panic("mock out the Get method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type RequesterSlice struct { +type RequesterSliceMock struct { // GetFunc mocks the Get method. GetFunc func(path string) ([]string, error) @@ -38,9 +38,9 @@ type RequesterSlice struct { } // Get calls GetFunc. -func (mock *RequesterSlice) Get(path string) ([]string, error) { +func (mock *RequesterSliceMock) Get(path string) ([]string, error) { if mock.GetFunc == nil { - panic("RequesterSlice.GetFunc: method is nil but RequesterSlice.Get was just called") + panic("RequesterSliceMock.GetFunc: method is nil but RequesterSlice.Get was just called") } callInfo := struct { Path string @@ -57,7 +57,7 @@ func (mock *RequesterSlice) Get(path string) ([]string, error) { // Check the length with: // // len(mockedRequesterSlice.GetCalls()) -func (mock *RequesterSlice) GetCalls() []struct { +func (mock *RequesterSliceMock) GetCalls() []struct { Path string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *RequesterSlice) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterSlice) ResetGetCalls() { +func (mock *RequesterSliceMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterSlice) ResetCalls() { +func (mock *RequesterSliceMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go index 3398b188..a7905429 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go @@ -8,12 +8,12 @@ import ( "sync" ) -// RequesterVariadic is a mock implementation of RequesterVariadic. +// RequesterVariadicMock is a mock implementation of RequesterVariadic. // // func TestSomethingThatUsesRequesterVariadic(t *testing.T) { // // // make and configure a mocked RequesterVariadic -// mockedRequesterVariadic := &RequesterVariadic{ +// mockedRequesterVariadic := &RequesterVariadicMock{ // GetFunc: func(values ...string) bool { // panic("mock out the Get method") // }, @@ -32,7 +32,7 @@ import ( // // and then make assertions. // // } -type RequesterVariadic struct { +type RequesterVariadicMock struct { // GetFunc mocks the Get method. GetFunc func(values ...string) bool @@ -79,9 +79,9 @@ type RequesterVariadic struct { } // Get calls GetFunc. -func (mock *RequesterVariadic) Get(values ...string) bool { +func (mock *RequesterVariadicMock) Get(values ...string) bool { if mock.GetFunc == nil { - panic("RequesterVariadic.GetFunc: method is nil but RequesterVariadic.Get was just called") + panic("RequesterVariadicMock.GetFunc: method is nil but RequesterVariadic.Get was just called") } callInfo := struct { Values []string @@ -98,7 +98,7 @@ func (mock *RequesterVariadic) Get(values ...string) bool { // Check the length with: // // len(mockedRequesterVariadic.GetCalls()) -func (mock *RequesterVariadic) GetCalls() []struct { +func (mock *RequesterVariadicMock) GetCalls() []struct { Values []string } { var calls []struct { @@ -111,16 +111,16 @@ func (mock *RequesterVariadic) GetCalls() []struct { } // ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterVariadic) ResetGetCalls() { +func (mock *RequesterVariadicMock) ResetGetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() } // MultiWriteToFile calls MultiWriteToFileFunc. -func (mock *RequesterVariadic) MultiWriteToFile(filename string, w ...io.Writer) string { +func (mock *RequesterVariadicMock) MultiWriteToFile(filename string, w ...io.Writer) string { if mock.MultiWriteToFileFunc == nil { - panic("RequesterVariadic.MultiWriteToFileFunc: method is nil but RequesterVariadic.MultiWriteToFile was just called") + panic("RequesterVariadicMock.MultiWriteToFileFunc: method is nil but RequesterVariadic.MultiWriteToFile was just called") } callInfo := struct { Filename string @@ -139,7 +139,7 @@ func (mock *RequesterVariadic) MultiWriteToFile(filename string, w ...io.Writer) // Check the length with: // // len(mockedRequesterVariadic.MultiWriteToFileCalls()) -func (mock *RequesterVariadic) MultiWriteToFileCalls() []struct { +func (mock *RequesterVariadicMock) MultiWriteToFileCalls() []struct { Filename string W []io.Writer } { @@ -154,16 +154,16 @@ func (mock *RequesterVariadic) MultiWriteToFileCalls() []struct { } // ResetMultiWriteToFileCalls reset all the calls that were made to MultiWriteToFile. -func (mock *RequesterVariadic) ResetMultiWriteToFileCalls() { +func (mock *RequesterVariadicMock) ResetMultiWriteToFileCalls() { mock.lockMultiWriteToFile.Lock() mock.calls.MultiWriteToFile = nil mock.lockMultiWriteToFile.Unlock() } // OneInterface calls OneInterfaceFunc. -func (mock *RequesterVariadic) OneInterface(a ...interface{}) bool { +func (mock *RequesterVariadicMock) OneInterface(a ...interface{}) bool { if mock.OneInterfaceFunc == nil { - panic("RequesterVariadic.OneInterfaceFunc: method is nil but RequesterVariadic.OneInterface was just called") + panic("RequesterVariadicMock.OneInterfaceFunc: method is nil but RequesterVariadic.OneInterface was just called") } callInfo := struct { A []interface{} @@ -180,7 +180,7 @@ func (mock *RequesterVariadic) OneInterface(a ...interface{}) bool { // Check the length with: // // len(mockedRequesterVariadic.OneInterfaceCalls()) -func (mock *RequesterVariadic) OneInterfaceCalls() []struct { +func (mock *RequesterVariadicMock) OneInterfaceCalls() []struct { A []interface{} } { var calls []struct { @@ -193,16 +193,16 @@ func (mock *RequesterVariadic) OneInterfaceCalls() []struct { } // ResetOneInterfaceCalls reset all the calls that were made to OneInterface. -func (mock *RequesterVariadic) ResetOneInterfaceCalls() { +func (mock *RequesterVariadicMock) ResetOneInterfaceCalls() { mock.lockOneInterface.Lock() mock.calls.OneInterface = nil mock.lockOneInterface.Unlock() } // Sprintf calls SprintfFunc. -func (mock *RequesterVariadic) Sprintf(format string, a ...interface{}) string { +func (mock *RequesterVariadicMock) Sprintf(format string, a ...interface{}) string { if mock.SprintfFunc == nil { - panic("RequesterVariadic.SprintfFunc: method is nil but RequesterVariadic.Sprintf was just called") + panic("RequesterVariadicMock.SprintfFunc: method is nil but RequesterVariadic.Sprintf was just called") } callInfo := struct { Format string @@ -221,7 +221,7 @@ func (mock *RequesterVariadic) Sprintf(format string, a ...interface{}) string { // Check the length with: // // len(mockedRequesterVariadic.SprintfCalls()) -func (mock *RequesterVariadic) SprintfCalls() []struct { +func (mock *RequesterVariadicMock) SprintfCalls() []struct { Format string A []interface{} } { @@ -236,14 +236,14 @@ func (mock *RequesterVariadic) SprintfCalls() []struct { } // ResetSprintfCalls reset all the calls that were made to Sprintf. -func (mock *RequesterVariadic) ResetSprintfCalls() { +func (mock *RequesterVariadicMock) ResetSprintfCalls() { mock.lockSprintf.Lock() mock.calls.Sprintf = nil mock.lockSprintf.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterVariadic) ResetCalls() { +func (mock *RequesterVariadicMock) ResetCalls() { mock.lockGet.Lock() mock.calls.Get = nil mock.lockGet.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go index 22109317..26fcae36 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Sibling is a mock implementation of Sibling. +// SiblingMock is a mock implementation of Sibling. // // func TestSomethingThatUsesSibling(t *testing.T) { // // // make and configure a mocked Sibling -// mockedSibling := &Sibling{ +// mockedSibling := &SiblingMock{ // DoSomethingFunc: func() { // panic("mock out the DoSomething method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Sibling struct { +type SiblingMock struct { // DoSomethingFunc mocks the DoSomething method. DoSomethingFunc func() @@ -36,9 +36,9 @@ type Sibling struct { } // DoSomething calls DoSomethingFunc. -func (mock *Sibling) DoSomething() { +func (mock *SiblingMock) DoSomething() { if mock.DoSomethingFunc == nil { - panic("Sibling.DoSomethingFunc: method is nil but Sibling.DoSomething was just called") + panic("SiblingMock.DoSomethingFunc: method is nil but Sibling.DoSomething was just called") } callInfo := struct { }{} @@ -52,7 +52,7 @@ func (mock *Sibling) DoSomething() { // Check the length with: // // len(mockedSibling.DoSomethingCalls()) -func (mock *Sibling) DoSomethingCalls() []struct { +func (mock *SiblingMock) DoSomethingCalls() []struct { } { var calls []struct { } @@ -63,14 +63,14 @@ func (mock *Sibling) DoSomethingCalls() []struct { } // ResetDoSomethingCalls reset all the calls that were made to DoSomething. -func (mock *Sibling) ResetDoSomethingCalls() { +func (mock *SiblingMock) ResetDoSomethingCalls() { mock.lockDoSomething.Lock() mock.calls.DoSomething = nil mock.lockDoSomething.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Sibling) ResetCalls() { +func (mock *SiblingMock) ResetCalls() { mock.lockDoSomething.Lock() mock.calls.DoSomething = nil mock.lockDoSomething.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go index 333933f9..456f63d3 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go @@ -7,12 +7,12 @@ import ( "sync" ) -// StructWithTag is a mock implementation of StructWithTag. +// StructWithTagMock is a mock implementation of StructWithTag. // // func TestSomethingThatUsesStructWithTag(t *testing.T) { // // // make and configure a mocked StructWithTag -// mockedStructWithTag := &StructWithTag{ +// mockedStructWithTag := &StructWithTagMock{ // MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { // panic("mock out the MethodA method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type StructWithTag struct { +type StructWithTagMock struct { // MethodAFunc mocks the MethodA method. MethodAFunc func(v *struct { FieldA int "json:\"field_a\"" @@ -47,7 +47,7 @@ type StructWithTag struct { } // MethodA calls MethodAFunc. -func (mock *StructWithTag) MethodA(v *struct { +func (mock *StructWithTagMock) MethodA(v *struct { FieldA int "json:\"field_a\"" FieldB int "json:\"field_b\" xml:\"field_b\"" }) *struct { @@ -55,7 +55,7 @@ func (mock *StructWithTag) MethodA(v *struct { FieldD int "json:\"field_d\" xml:\"field_d\"" } { if mock.MethodAFunc == nil { - panic("StructWithTag.MethodAFunc: method is nil but StructWithTag.MethodA was just called") + panic("StructWithTagMock.MethodAFunc: method is nil but StructWithTag.MethodA was just called") } callInfo := struct { V *struct { @@ -75,7 +75,7 @@ func (mock *StructWithTag) MethodA(v *struct { // Check the length with: // // len(mockedStructWithTag.MethodACalls()) -func (mock *StructWithTag) MethodACalls() []struct { +func (mock *StructWithTagMock) MethodACalls() []struct { V *struct { FieldA int "json:\"field_a\"" FieldB int "json:\"field_b\" xml:\"field_b\"" @@ -94,14 +94,14 @@ func (mock *StructWithTag) MethodACalls() []struct { } // ResetMethodACalls reset all the calls that were made to MethodA. -func (mock *StructWithTag) ResetMethodACalls() { +func (mock *StructWithTagMock) ResetMethodACalls() { mock.lockMethodA.Lock() mock.calls.MethodA = nil mock.lockMethodA.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *StructWithTag) ResetCalls() { +func (mock *StructWithTagMock) ResetCalls() { mock.lockMethodA.Lock() mock.calls.MethodA = nil mock.lockMethodA.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go index e9e32372..1b55833e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go @@ -9,12 +9,12 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// UsesOtherPkgIface is a mock implementation of UsesOtherPkgIface. +// UsesOtherPkgIfaceMock is a mock implementation of UsesOtherPkgIface. // // func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { // // // make and configure a mocked UsesOtherPkgIface -// mockedUsesOtherPkgIface := &UsesOtherPkgIface{ +// mockedUsesOtherPkgIface := &UsesOtherPkgIfaceMock{ // DoSomethingElseFunc: func(obj test.Sibling) { // panic("mock out the DoSomethingElse method") // }, @@ -24,7 +24,7 @@ import ( // // and then make assertions. // // } -type UsesOtherPkgIface struct { +type UsesOtherPkgIfaceMock struct { // DoSomethingElseFunc mocks the DoSomethingElse method. DoSomethingElseFunc func(obj test.Sibling) @@ -40,9 +40,9 @@ type UsesOtherPkgIface struct { } // DoSomethingElse calls DoSomethingElseFunc. -func (mock *UsesOtherPkgIface) DoSomethingElse(obj test.Sibling) { +func (mock *UsesOtherPkgIfaceMock) DoSomethingElse(obj test.Sibling) { if mock.DoSomethingElseFunc == nil { - panic("UsesOtherPkgIface.DoSomethingElseFunc: method is nil but UsesOtherPkgIface.DoSomethingElse was just called") + panic("UsesOtherPkgIfaceMock.DoSomethingElseFunc: method is nil but UsesOtherPkgIface.DoSomethingElse was just called") } callInfo := struct { Obj test.Sibling @@ -59,7 +59,7 @@ func (mock *UsesOtherPkgIface) DoSomethingElse(obj test.Sibling) { // Check the length with: // // len(mockedUsesOtherPkgIface.DoSomethingElseCalls()) -func (mock *UsesOtherPkgIface) DoSomethingElseCalls() []struct { +func (mock *UsesOtherPkgIfaceMock) DoSomethingElseCalls() []struct { Obj test.Sibling } { var calls []struct { @@ -72,14 +72,14 @@ func (mock *UsesOtherPkgIface) DoSomethingElseCalls() []struct { } // ResetDoSomethingElseCalls reset all the calls that were made to DoSomethingElse. -func (mock *UsesOtherPkgIface) ResetDoSomethingElseCalls() { +func (mock *UsesOtherPkgIfaceMock) ResetDoSomethingElseCalls() { mock.lockDoSomethingElse.Lock() mock.calls.DoSomethingElse = nil mock.lockDoSomethingElse.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *UsesOtherPkgIface) ResetCalls() { +func (mock *UsesOtherPkgIfaceMock) ResetCalls() { mock.lockDoSomethingElse.Lock() mock.calls.DoSomethingElse = nil mock.lockDoSomethingElse.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go index 65620671..8eb17b94 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go @@ -7,12 +7,12 @@ import ( "sync" ) -// Variadic is a mock implementation of Variadic. +// VariadicMock is a mock implementation of Variadic. // // func TestSomethingThatUsesVariadic(t *testing.T) { // // // make and configure a mocked Variadic -// mockedVariadic := &Variadic{ +// mockedVariadic := &VariadicMock{ // VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { // panic("mock out the VariadicFunction method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type Variadic struct { +type VariadicMock struct { // VariadicFunctionFunc mocks the VariadicFunction method. VariadicFunctionFunc func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error @@ -40,9 +40,9 @@ type Variadic struct { } // VariadicFunction calls VariadicFunctionFunc. -func (mock *Variadic) VariadicFunction(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { +func (mock *VariadicMock) VariadicFunction(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { if mock.VariadicFunctionFunc == nil { - panic("Variadic.VariadicFunctionFunc: method is nil but Variadic.VariadicFunction was just called") + panic("VariadicMock.VariadicFunctionFunc: method is nil but Variadic.VariadicFunction was just called") } callInfo := struct { Str string @@ -61,7 +61,7 @@ func (mock *Variadic) VariadicFunction(str string, vFunc func(args1 string, args // Check the length with: // // len(mockedVariadic.VariadicFunctionCalls()) -func (mock *Variadic) VariadicFunctionCalls() []struct { +func (mock *VariadicMock) VariadicFunctionCalls() []struct { Str string VFunc func(args1 string, args2 ...interface{}) interface{} } { @@ -76,14 +76,14 @@ func (mock *Variadic) VariadicFunctionCalls() []struct { } // ResetVariadicFunctionCalls reset all the calls that were made to VariadicFunction. -func (mock *Variadic) ResetVariadicFunctionCalls() { +func (mock *VariadicMock) ResetVariadicFunctionCalls() { mock.lockVariadicFunction.Lock() mock.calls.VariadicFunction = nil mock.lockVariadicFunction.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Variadic) ResetCalls() { +func (mock *VariadicMock) ResetCalls() { mock.lockVariadicFunction.Lock() mock.calls.VariadicFunction = nil mock.lockVariadicFunction.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go index fdfca4a5..6a8f78a6 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go @@ -7,12 +7,12 @@ import ( "sync" ) -// VariadicNoReturnInterface is a mock implementation of VariadicNoReturnInterface. +// VariadicNoReturnInterfaceMock is a mock implementation of VariadicNoReturnInterface. // // func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { // // // make and configure a mocked VariadicNoReturnInterface -// mockedVariadicNoReturnInterface := &VariadicNoReturnInterface{ +// mockedVariadicNoReturnInterface := &VariadicNoReturnInterfaceMock{ // VariadicNoReturnFunc: func(j int, is ...interface{}) { // panic("mock out the VariadicNoReturn method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type VariadicNoReturnInterface struct { +type VariadicNoReturnInterfaceMock struct { // VariadicNoReturnFunc mocks the VariadicNoReturn method. VariadicNoReturnFunc func(j int, is ...interface{}) @@ -40,9 +40,9 @@ type VariadicNoReturnInterface struct { } // VariadicNoReturn calls VariadicNoReturnFunc. -func (mock *VariadicNoReturnInterface) VariadicNoReturn(j int, is ...interface{}) { +func (mock *VariadicNoReturnInterfaceMock) VariadicNoReturn(j int, is ...interface{}) { if mock.VariadicNoReturnFunc == nil { - panic("VariadicNoReturnInterface.VariadicNoReturnFunc: method is nil but VariadicNoReturnInterface.VariadicNoReturn was just called") + panic("VariadicNoReturnInterfaceMock.VariadicNoReturnFunc: method is nil but VariadicNoReturnInterface.VariadicNoReturn was just called") } callInfo := struct { J int @@ -61,7 +61,7 @@ func (mock *VariadicNoReturnInterface) VariadicNoReturn(j int, is ...interface{} // Check the length with: // // len(mockedVariadicNoReturnInterface.VariadicNoReturnCalls()) -func (mock *VariadicNoReturnInterface) VariadicNoReturnCalls() []struct { +func (mock *VariadicNoReturnInterfaceMock) VariadicNoReturnCalls() []struct { J int Is []interface{} } { @@ -76,14 +76,14 @@ func (mock *VariadicNoReturnInterface) VariadicNoReturnCalls() []struct { } // ResetVariadicNoReturnCalls reset all the calls that were made to VariadicNoReturn. -func (mock *VariadicNoReturnInterface) ResetVariadicNoReturnCalls() { +func (mock *VariadicNoReturnInterfaceMock) ResetVariadicNoReturnCalls() { mock.lockVariadicNoReturn.Lock() mock.calls.VariadicNoReturn = nil mock.lockVariadicNoReturn.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *VariadicNoReturnInterface) ResetCalls() { +func (mock *VariadicNoReturnInterfaceMock) ResetCalls() { mock.lockVariadicNoReturn.Lock() mock.calls.VariadicNoReturn = nil mock.lockVariadicNoReturn.Unlock() diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go index 1bf44070..cd05c24a 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go @@ -7,12 +7,12 @@ import ( "sync" ) -// VariadicReturnFunc is a mock implementation of VariadicReturnFunc. +// VariadicReturnFuncMock is a mock implementation of VariadicReturnFunc. // // func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { // // // make and configure a mocked VariadicReturnFunc -// mockedVariadicReturnFunc := &VariadicReturnFunc{ +// mockedVariadicReturnFunc := &VariadicReturnFuncMock{ // SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { // panic("mock out the SampleMethod method") // }, @@ -22,7 +22,7 @@ import ( // // and then make assertions. // // } -type VariadicReturnFunc struct { +type VariadicReturnFuncMock struct { // SampleMethodFunc mocks the SampleMethod method. SampleMethodFunc func(str string) func(str string, arr []int, a ...interface{}) @@ -38,9 +38,9 @@ type VariadicReturnFunc struct { } // SampleMethod calls SampleMethodFunc. -func (mock *VariadicReturnFunc) SampleMethod(str string) func(str string, arr []int, a ...interface{}) { +func (mock *VariadicReturnFuncMock) SampleMethod(str string) func(str string, arr []int, a ...interface{}) { if mock.SampleMethodFunc == nil { - panic("VariadicReturnFunc.SampleMethodFunc: method is nil but VariadicReturnFunc.SampleMethod was just called") + panic("VariadicReturnFuncMock.SampleMethodFunc: method is nil but VariadicReturnFunc.SampleMethod was just called") } callInfo := struct { Str string @@ -57,7 +57,7 @@ func (mock *VariadicReturnFunc) SampleMethod(str string) func(str string, arr [] // Check the length with: // // len(mockedVariadicReturnFunc.SampleMethodCalls()) -func (mock *VariadicReturnFunc) SampleMethodCalls() []struct { +func (mock *VariadicReturnFuncMock) SampleMethodCalls() []struct { Str string } { var calls []struct { @@ -70,14 +70,14 @@ func (mock *VariadicReturnFunc) SampleMethodCalls() []struct { } // ResetSampleMethodCalls reset all the calls that were made to SampleMethod. -func (mock *VariadicReturnFunc) ResetSampleMethodCalls() { +func (mock *VariadicReturnFuncMock) ResetSampleMethodCalls() { mock.lockSampleMethod.Lock() mock.calls.SampleMethod = nil mock.lockSampleMethod.Unlock() } // ResetCalls reset all the calls that were made to all mocked methods. -func (mock *VariadicReturnFunc) ResetCalls() { +func (mock *VariadicReturnFuncMock) ResetCalls() { mock.lockSampleMethod.Lock() mock.calls.SampleMethod = nil mock.lockSampleMethod.Unlock() From 587f1972a2765eae2e2a96dc1811da8a0af3c655 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 13:58:37 -0600 Subject: [PATCH 38/50] update docs and moq config --- .mockery-moq.yaml | 4 +- docs/configuration.md | 5 +- docs/features.md | 117 ++++++++++++++++++++++++++++++++++++++++++ docs/requirements.txt | 4 +- mkdocs.yml | 3 +- 5 files changed, 127 insertions(+), 6 deletions(-) diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 4ddeb002..0d44a9b5 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -1,8 +1,8 @@ quiet: False disable-version-string: True with-expecter: True -mockname: "{{.InterfaceName}}" -filename: "{{.MockName}}.go" +mockname: "{{.InterfaceName}}Mock" +filename: "{{.InterfaceName}}.go" dir: "mocks/moq/{{.PackagePath}}" packages: github.com/vektra/mockery/v2/pkg/fixtures: diff --git a/docs/configuration.md b/docs/configuration.md index c3bfcd6b..27be9cda 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -73,14 +73,15 @@ Parameter Descriptions | `include-regex` | :fontawesome-solid-x: | `#!yaml ""` | When set, only interface names that match the expression will be generated. This setting is ignored if `all: True` is specified in the configuration. To further refine the interfaces generated, use `exclude-regex`. | | `inpackage` | :fontawesome-solid-x: | `#!yaml false` | When generating mocks alongside the original interfaces, you must specify `inpackage: True` to inform mockery that the mock is being placed in the same package as the original interface. | | `log-level` | :fontawesome-solid-x: | `#!yaml "info"` | Set the level of the logger | -| `mock-build-tags` | :fontawesome-solid-x: | `#!yaml ""` | Set the build tags of the generated mocks. Read more about the [format](https://pkg.go.dev/cmd/go#hdr-Build_constraints). | +| `mock-build-tags` | :fontawesome-solid-x: | `#!yaml ""` | Set the build tags of the generated mocks. Read more about the [format](https://pkg.go.dev/cmd/go#hdr-Build_constraints). | | `mockname` | :fontawesome-solid-check: | `#!yaml "Mock{{.InterfaceName}}"` | The name of the generated mock. | | `outpkg` | :fontawesome-solid-check: | `#!yaml "{{.PackageName}}"` | Use `outpkg` to specify the package name of the generated mocks. | | [`packages`](features.md#packages-configuration) | :fontawesome-solid-x: | `#!yaml null` | A dictionary containing configuration describing the packages and interfaces to generate mocks for. | | `print` | :fontawesome-solid-x: | `#!yaml false` | Use `print: True` to have the resulting code printed out instead of written to disk. | | [`recursive`](features.md#recursive-package-discovery) | :fontawesome-solid-x: | `#!yaml false` | When set to `true` on a particular package, mockery will recursively search for all sub-packages and inject those packages into the config map. | | [`replace-type`](features.md#replace-types) | :fontawesome-solid-x: | `#!yaml null` | Replaces aliases, packages and/or types during generation. | -| `tags` | :fontawesome-solid-x: | `#!yaml ""` | A space-separated list of additional build tags to load packages. | +| [`style`](/mockery/features/#mock-styles) | :fontawesome-solid-x: | `#!yaml mockery` | Set the style of mocks to generate. | +| `tags` | :fontawesome-solid-x: | `#!yaml ""` | A space-separated list of additional build tags to load packages. | | [`with-expecter`](features.md#expecter-structs) | :fontawesome-solid-x: | `#!yaml true` | Use `with-expecter: True` to generate `EXPECT()` methods for your mocks. This is the preferred way to setup your mocks. | Layouts diff --git a/docs/features.md b/docs/features.md index 9d320f98..cbc7ab4a 100644 --- a/docs/features.md +++ b/docs/features.md @@ -1,6 +1,123 @@ Features ======== +Mock Styles +------------ + +:octicons-tag-24: v2.42.0 :material-test-tube:{ .tooltip foo } + +!!! warning "ALPHA" + This feature is currently in alpha. Usage is not recommended for production applications as the configuration semantics and/or mock behavior might change in future releases. + +mockery provides a parameter called `#!yaml style:` that allows you to specify different styles of mock implementations. This parameter defaults to `#!yaml style: mockery`, but you may also provide other values described below: + +| style | description | +|-------|-------------| +| `mockery` | The default style. Generates the mocks that you typically expect from this project. | +| `moq` | Generates mocks in the style of [Mat Ryer's project](https://github.com/matryer/moq). | + +This table describes the characteristics of each mock style. + +| feature | `mockery` | `moq` | +|---------|-----------|-------| +| Uses testify | :white_check_mark: | :x: | +| Strictly typed arguments | :warning:[^1] | :white_check_mark: | +| Stricly typed return values | :white_check_mark: | :white_check_mark: | +| Multiple mocks per file | :x: | :x: | +| Return values mapped from argument values | :white_check_mark: | :x: | +| Supports generics | :white_check_mark: | :white_check_mark: | +| + +[^1]: + If you use the `.RunAndReturn` method in the [`.EXPECT()`](/mockery/features/#expecter-structs) structs, you can get strict type safety. Otherwise, `.EXPECT()` methods are type-safe-ish, meaning you'll get compiler errors if you have the incorrect number of arguments, but the types of the arguments themselves are `interface{}` due to the need to specify `mock.Anything` in some cases. + +### `mockery` + +`mockery` is the default style of mocks you are used to with this project. + +### `moq` + +The `moq` implementations are generated using similar logic as the project at https://github.com/matryer/moq. The mocks rely on you defining stub functions that will be called directly from each method. For example, assume you have an interface like this: + +```go +type Requester interface { + Get(path string) (string, error) +} +``` + +`moq` will create an implementation that looks roughly like this: + +```go +type RequesterMock struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterMock) Get(path string) (string, error) { + if mock.GetFunc == nil { + panic("RequesterMock.GetFunc: method is nil but Requester.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} +``` + +The way you interact with this mock in a test would look like this: + +```go +func TestRequester(t *testing.T){ + requesterMock := &RequesterMock{ + GetFunc: func(path string) (string, error) { + return "value", fmt.Errorf("failed") + } + } +} +``` + +#### Configuration + +A simple basic configuration might look like this: + +```yaml +style: moq +packages: + github.com/vektra/mockery/v2/pkg/fixtures: + config: + template-map: + with-resets: true + skip-ensure: true + stub-impl: false +``` + +The `moq` style is driven entirely off of Go templates. Various features of the moq may be toggled by using the `#! template-map:` mapping. These are the moq-specific parameters: + +| name | default | description | +|------|---------|-------------| +| `#!yaml with-resets` | `` | Generates functions that aid in resetting the list of calls made to a mock. | +| `#!yaml skip-ensure` | `` | Skips adding a compile-time check that asserts the generated mock properly implements the interface. | +| `#!yaml stub-impl` | `` | Sets methods to return the zero value when no mock implementation is provided. | + +!!! note + Many of the parameters listed in the [parameter descriptions page](/mockery/configuration/#parameter-descriptions) also apply to `moq`. However, some parameters of `mockery`-styled mocks will not apply to `moq`. Efforts will be made to ensure the documentation is clear on which parameters apply to which style. + Replace Types ------------- diff --git a/docs/requirements.txt b/docs/requirements.txt index eeffbcf5..d86c6994 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,9 @@ mike @ git+https://github.com/jimporter/mike.git mkdocs mkdocs-glightbox -git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git +# replace the below mkdocs-material line below with "mkdocs-material" +# if you don't have access to the insiders edition. +git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git@9.5.5-insiders-4.51.0 mkdocs-open-in-new-tab cairosvg pillow diff --git a/mkdocs.yml b/mkdocs.yml index 2c59e576..0e41ddd9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -31,6 +31,7 @@ theme: - content.code.copy - content.action.edit - content.action.view + - content.footnote.tooltips - navigation.indexes - navigation.sections - navigation.tracking @@ -38,6 +39,7 @@ theme: markdown_extensions: - admonition - attr_list + - footnotes - md_in_html - pymdownx.emoji: emoji_index: !!python/name:material.extensions.emoji.twemoji @@ -53,7 +55,6 @@ markdown_extensions: alternate_style: true - toc: permalink: true - nav: - Home: index.md From 1805cf2fcba394b13f20e4aedfaa4264dde6e404 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 14:12:44 -0600 Subject: [PATCH 39/50] fix tests --- pkg/config/config_test.go | 9 ++++++--- pkg/fixtures/variadic.go | 1 - pkg/outputter_test.go | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 94ff3fa7..11eb4b8f 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -908,6 +908,7 @@ func TestNewConfigFromViper(t *testing.T) { Case: "camel", Dir: ".", Output: "./mocks", + Style: "mockery", }, }, { @@ -919,11 +920,13 @@ packages: want: &Config{ Dir: "mocks/{{.PackagePath}}", FileName: "mock_{{.InterfaceName}}.go", + Formatter: "goimports", IncludeAutoGenerated: true, MockName: "Mock{{.InterfaceName}}", Outpkg: "{{.PackageName}}", WithExpecter: true, LogLevel: "info", + Style: "mockery", }, }, { @@ -937,11 +940,13 @@ packages: want: &Config{ Dir: "barfoo", FileName: "foobar.go", + Formatter: "goimports", IncludeAutoGenerated: true, MockName: "Mock{{.InterfaceName}}", Outpkg: "{{.PackageName}}", WithExpecter: true, LogLevel: "info", + Style: "mockery", }, }, } @@ -974,9 +979,7 @@ packages: got._cfgAsMap = nil tt.want._cfgAsMap = nil - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewConfigFromViper() = %v, want %v", got, tt.want) - } + assert.Equal(t, tt.want, got) }) } } diff --git a/pkg/fixtures/variadic.go b/pkg/fixtures/variadic.go index 3e08465b..ef54df26 100644 --- a/pkg/fixtures/variadic.go +++ b/pkg/fixtures/variadic.go @@ -5,4 +5,3 @@ type VariadicFunction = func(args1 string, args2 ...interface{}) interface{} type Variadic interface { VariadicFunction(str string, vFunc VariadicFunction) error } - diff --git a/pkg/outputter_test.go b/pkg/outputter_test.go index 8c7b860c..c98f995e 100644 --- a/pkg/outputter_test.go +++ b/pkg/outputter_test.go @@ -226,7 +226,9 @@ func TestOutputter_Generate(t *testing.T) { } for _, tt := range tests { if tt.fields.config == nil { - tt.fields.config = &config.Config{} + tt.fields.config = &config.Config{ + Style: "mockery", + } } tt.fields.config.Dir = t.TempDir() tt.fields.config.MockName = "Mock{{.InterfaceName}}" From cdd540bfbbb7f28f3120ad6c4c5289f30c7fecb0 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 14:31:24 -0600 Subject: [PATCH 40/50] Fix issue with ordering of filesystem walk --- pkg/config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 84c2104a..e0a875eb 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -621,7 +621,16 @@ func (c *Config) subPackages( } } - pathLog.Debug().Msg("subdirectory has a .go file, adding this path to packages config") + pathLog.Debug().Msg("subdirectory has a .go file") + goModExists, err := path.Parent().Join("go.mod").Exists() + if err != nil { + pathLog.Err(err).Msg("failed to determine if go.mod exists") + return err + } + if goModExists { + pathLog.Debug().Msg("found .go file, but go.mod exists. Skipping.") + return pathlib.ErrWalkSkipSubtree + } subdirectoriesWithGoFiles = append(subdirectoriesWithGoFiles, path.Parent()) visitedDirs[path.Parent().String()] = nil } From 7f4d02d0834d1be298d3cf3736e7ac1a7f3b4d75 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Tue, 13 Feb 2024 14:37:13 -0600 Subject: [PATCH 41/50] fix to go.mod logic --- pkg/config/config.go | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index e0a875eb..63c0a8a3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -535,6 +535,21 @@ func isAutoGenerated(path *pathlib.Path) (bool, error) { return false, nil } +func shouldExcludeModule(ctx context.Context, root *pathlib.Path, goModPath *pathlib.Path) (bool, error) { + log := zerolog.Ctx(ctx) + relative, err := goModPath.RelativeTo(root) + if err != nil { + return false, stackerr.NewStackErrf(err, "determining distance from search root") + } + + if len(relative.Parts()) != 1 { + log.Debug().Msg("skipping sub-module") + return true, nil + } + log.Debug().Int("parts_len", len(relative.Parts())).Str("parts", fmt.Sprintf("%v", relative.Parts())).Msg("not skipping module as this is the root path") + return false, nil +} + func (c *Config) subPackages( ctx context.Context, pkgPath string, @@ -592,18 +607,14 @@ func (c *Config) subPackages( } if path.Name() == "go.mod" { pathLog.Debug().Msg("path contains go.mod file") - // Check if our current depth is 0. We do this to skip sub-modules, but not - // the root module. - relative, err := path.RelativeTo(searchRoot) + shouldExclude, err := shouldExcludeModule(ctx, searchRoot, path) if err != nil { - return stackerr.NewStackErrf(err, "determining distance from search root") + return err } - - if len(relative.Parts()) != 1 { - pathLog.Debug().Msg("skipping sub-module") + if shouldExclude { return pathlib.ErrWalkSkipSubtree } - pathLog.Debug().Int("parts_len", len(relative.Parts())).Str("parts", fmt.Sprintf("%v", relative.Parts())).Msg("not skipping module as this is the root path") + return nil } _, haveVisitedDir := visitedDirs[path.Parent().String()] @@ -622,14 +633,20 @@ func (c *Config) subPackages( } pathLog.Debug().Msg("subdirectory has a .go file") - goModExists, err := path.Parent().Join("go.mod").Exists() + goModPath := path.Parent().Join("go.mod") + goModExists, err := goModPath.Exists() if err != nil { pathLog.Err(err).Msg("failed to determine if go.mod exists") return err } if goModExists { - pathLog.Debug().Msg("found .go file, but go.mod exists. Skipping.") - return pathlib.ErrWalkSkipSubtree + shouldExclude, err := shouldExcludeModule(ctx, searchRoot, goModPath) + if err != nil { + return err + } + if shouldExclude { + return pathlib.ErrWalkSkipSubtree + } } subdirectoriesWithGoFiles = append(subdirectoriesWithGoFiles, path.Parent()) visitedDirs[path.Parent().String()] = nil From 78eb414b3571a00a47da41262186531852534812 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 13:28:00 -0600 Subject: [PATCH 42/50] Add context.Context to more moq functions for logging --- pkg/config/config.go | 1 - pkg/fixtures/inpackage/README.md | 1 + pkg/fixtures/inpackage/foo.go | 9 +++ pkg/fixtures/recursive_generation/Foo_mock.go | 77 ------------------- .../recursive_generation/subpkg1/Foo_mock.go | 77 ------------------- .../recursive_generation/subpkg2/Foo_mock.go | 77 ------------------- .../Foo_mock.go | 77 ------------------- pkg/generator/template_generator.go | 22 +++--- pkg/outputter.go | 2 +- pkg/registry/method_scope.go | 33 ++++---- pkg/registry/registry.go | 6 +- 11 files changed, 45 insertions(+), 337 deletions(-) create mode 100644 pkg/fixtures/inpackage/README.md create mode 100644 pkg/fixtures/inpackage/foo.go delete mode 100644 pkg/fixtures/recursive_generation/Foo_mock.go delete mode 100644 pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go delete mode 100644 pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go delete mode 100644 pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go diff --git a/pkg/config/config.go b/pkg/config/config.go index 63c0a8a3..3e394e06 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -66,7 +66,6 @@ type Config struct { Quiet bool `mapstructure:"quiet"` Recursive bool `mapstructure:"recursive"` ReplaceType []string `mapstructure:"replace-type"` - SkipEnsure bool `mapstructure:"skip-ensure"` SrcPkg string `mapstructure:"srcpkg"` Style string `mapstructure:"style"` // StructName overrides the name given to the mock struct and should only be nonempty diff --git a/pkg/fixtures/inpackage/README.md b/pkg/fixtures/inpackage/README.md new file mode 100644 index 00000000..debaaddc --- /dev/null +++ b/pkg/fixtures/inpackage/README.md @@ -0,0 +1 @@ +This package is to test mocks that are generated next to the original interface. \ No newline at end of file diff --git a/pkg/fixtures/inpackage/foo.go b/pkg/fixtures/inpackage/foo.go new file mode 100644 index 00000000..758a65cf --- /dev/null +++ b/pkg/fixtures/inpackage/foo.go @@ -0,0 +1,9 @@ +package inpackage + +type ArgType string + +type ReturnType string + +type Foo interface { + Get(key ArgType) ReturnType +} diff --git a/pkg/fixtures/recursive_generation/Foo_mock.go b/pkg/fixtures/recursive_generation/Foo_mock.go deleted file mode 100644 index 1374b9fa..00000000 --- a/pkg/fixtures/recursive_generation/Foo_mock.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package recursive_generation - -import mock "github.com/stretchr/testify/mock" - -// MockFoo is an autogenerated mock type for the Foo type -type MockFoo struct { - mock.Mock -} - -type MockFoo_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFoo) EXPECT() *MockFoo_Expecter { - return &MockFoo_Expecter{mock: &_m.Mock} -} - -// Get provides a mock function with given fields: -func (_m *MockFoo) Get() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockFoo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { - return &MockFoo_Get_Call{Call: _e.mock.On("Get")} -} - -func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockFoo(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFoo { - mock := &MockFoo{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go deleted file mode 100644 index 50697c1d..00000000 --- a/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package subpkg1 - -import mock "github.com/stretchr/testify/mock" - -// MockFoo is an autogenerated mock type for the Foo type -type MockFoo struct { - mock.Mock -} - -type MockFoo_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFoo) EXPECT() *MockFoo_Expecter { - return &MockFoo_Expecter{mock: &_m.Mock} -} - -// Get provides a mock function with given fields: -func (_m *MockFoo) Get() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockFoo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { - return &MockFoo_Get_Call{Call: _e.mock.On("Get")} -} - -func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockFoo(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFoo { - mock := &MockFoo{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go deleted file mode 100644 index fe92d118..00000000 --- a/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package subpkg2 - -import mock "github.com/stretchr/testify/mock" - -// MockFoo is an autogenerated mock type for the Foo type -type MockFoo struct { - mock.Mock -} - -type MockFoo_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFoo) EXPECT() *MockFoo_Expecter { - return &MockFoo_Expecter{mock: &_m.Mock} -} - -// Get provides a mock function with given fields: -func (_m *MockFoo) Get() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockFoo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { - return &MockFoo_Get_Call{Call: _e.mock.On("Get")} -} - -func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockFoo(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFoo { - mock := &MockFoo{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go deleted file mode 100644 index 9648bcfd..00000000 --- a/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package subpkg_with_only_autogenerated_files - -import mock "github.com/stretchr/testify/mock" - -// MockFoo is an autogenerated mock type for the Foo type -type MockFoo struct { - mock.Mock -} - -type MockFoo_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFoo) EXPECT() *MockFoo_Expecter { - return &MockFoo_Expecter{mock: &_m.Mock} -} - -// Get provides a mock function with given fields: -func (_m *MockFoo) Get() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockFoo_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { - return &MockFoo_Get_Call{Call: _e.mock.On("Get")} -} - -func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockFoo(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFoo { - mock := &MockFoo{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/generator/template_generator.go b/pkg/generator/template_generator.go index 806d29e9..bb180093 100644 --- a/pkg/generator/template_generator.go +++ b/pkg/generator/template_generator.go @@ -50,7 +50,7 @@ func (g *TemplateGenerator) format(src []byte, ifaceConfig *config.Config) ([]by return gofmt(src) } -func (g *TemplateGenerator) methodData(method *types.Func) template.MethodData { +func (g *TemplateGenerator) methodData(ctx context.Context, method *types.Func) template.MethodData { methodScope := g.registry.MethodScope() signature := method.Type().(*types.Signature) @@ -58,7 +58,7 @@ func (g *TemplateGenerator) methodData(method *types.Func) template.MethodData { for j := 0; j < signature.Params().Len(); j++ { param := signature.Params().At(j) params[j] = template.ParamData{ - Var: methodScope.AddVar(param, ""), + Var: methodScope.AddVar(ctx, param, ""), Variadic: signature.Variadic() && j == signature.Params().Len()-1, } } @@ -67,7 +67,7 @@ func (g *TemplateGenerator) methodData(method *types.Func) template.MethodData { for j := 0; j < signature.Results().Len(); j++ { param := signature.Results().At(j) returns[j] = template.ParamData{ - Var: methodScope.AddVar(param, "Out"), + Var: methodScope.AddVar(ctx, param, "Out"), Variadic: false, } } @@ -94,7 +94,7 @@ func explicitConstraintType(typeParam *types.Var) (t types.Type) { return nil } -func (g *TemplateGenerator) typeParams(tparams *types.TypeParamList) []template.TypeParamData { +func (g *TemplateGenerator) typeParams(ctx context.Context, tparams *types.TypeParamList) []template.TypeParamData { var tpd []template.TypeParamData if tparams == nil { return tpd @@ -107,7 +107,7 @@ func (g *TemplateGenerator) typeParams(tparams *types.TypeParamList) []template. tp := tparams.At(i) typeParam := types.NewParam(token.Pos(i), tp.Obj().Pkg(), tp.Obj().Name(), tp.Constraint()) tpd[i] = template.TypeParamData{ - ParamData: template.ParamData{Var: scope.AddVar(typeParam, "")}, + ParamData: template.ParamData{Var: scope.AddVar(ctx, typeParam, "")}, Constraint: explicitConstraintType(typeParam), } } @@ -126,7 +126,7 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac methods := make([]template.MethodData, iface.NumMethods()) for i := 0; i < iface.NumMethods(); i++ { - methods[i] = g.methodData(iface.Method(i)) + methods[i] = g.methodData(ctx, iface.Method(i)) } // For now, mockery only supports one mock per file, which is why we're creating @@ -135,7 +135,7 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac { InterfaceName: ifaceName, MockName: ifaceConfig.MockName, - TypeParams: g.typeParams(tparams), + TypeParams: g.typeParams(ctx, tparams), Methods: methods, }, } @@ -147,13 +147,15 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac } if data.MocksSomeMethod() { log.Debug().Msg("interface mocks some method, importing sync package") - g.registry.AddImport(types.NewPackage("sync", "sync")) + g.registry.AddImport(ctx, types.NewPackage("sync", "sync")) } + if g.registry.SrcPkgName() != ifaceConfig.Outpkg { data.SrcPkgQualifier = g.registry.SrcPkgName() + "." - if !ifaceConfig.SkipEnsure { + skipEnsure, ok := ifaceConfig.TemplateMap["skip-ensure"] + if !ok || !skipEnsure.(bool) { log.Debug().Str("src-pkg", g.registry.SrcPkg().Path()).Msg("skip-ensure is false. Adding import for source package.") - imprt := g.registry.AddImport(g.registry.SrcPkg()) + imprt := g.registry.AddImport(ctx, g.registry.SrcPkg()) log.Debug().Msgf("imprt: %v", imprt) data.SrcPkgQualifier = imprt.Qualifier() + "." } diff --git a/pkg/outputter.go b/pkg/outputter.go index 2fdba2c5..5d2a36e7 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -334,7 +334,7 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } continue } - logging.WarnAlpha(ifaceCtx, "usage mock styles other than mockery is currently in an alpha state.", nil) + logging.WarnAlpha(ifaceCtx, "usage of mock styles other than mockery is currently in an alpha state.", nil) ifaceLog.Debug().Msg("generating templated mock") config := generator.TemplateGeneratorConfig{ diff --git a/pkg/registry/method_scope.go b/pkg/registry/method_scope.go index 8d301342..c832da0a 100644 --- a/pkg/registry/method_scope.go +++ b/pkg/registry/method_scope.go @@ -1,6 +1,7 @@ package registry import ( + "context" "go/types" "strconv" ) @@ -22,9 +23,9 @@ type MethodScope struct { // Variables names are generated if required and are ensured to be // without conflict with other variables and imported packages. It also // adds the relevant imports to the registry for each added variable. -func (m *MethodScope) AddVar(vr *types.Var, suffix string) *Var { +func (m *MethodScope) AddVar(ctx context.Context, vr *types.Var, suffix string) *Var { imports := make(map[string]*Package) - m.populateImports(vr.Type(), imports) + m.populateImports(ctx, vr.Type(), imports) m.resolveImportVarConflicts(imports) name := varName(vr, suffix) @@ -76,55 +77,55 @@ func (m MethodScope) searchVar(name string) (*Var, bool) { // populateImports extracts all the package imports for a given type // recursively. The imported packages by a single type can be more than // one (ex: map[a.Type]b.Type). -func (m MethodScope) populateImports(t types.Type, imports map[string]*Package) { +func (m MethodScope) populateImports(ctx context.Context, t types.Type, imports map[string]*Package) { switch t := t.(type) { case *types.Named: if pkg := t.Obj().Pkg(); pkg != nil { - imports[pkg.Path()] = m.registry.AddImport(pkg) + imports[pkg.Path()] = m.registry.AddImport(ctx, pkg) } // The imports of a Type with a TypeList must be added to the imports list // For example: Foo[otherpackage.Bar] , must have otherpackage imported if targs := t.TypeArgs(); targs != nil { for i := 0; i < targs.Len(); i++ { - m.populateImports(targs.At(i), imports) + m.populateImports(ctx, targs.At(i), imports) } } case *types.Array: - m.populateImports(t.Elem(), imports) + m.populateImports(ctx, t.Elem(), imports) case *types.Slice: - m.populateImports(t.Elem(), imports) + m.populateImports(ctx, t.Elem(), imports) case *types.Signature: for i := 0; i < t.Params().Len(); i++ { - m.populateImports(t.Params().At(i).Type(), imports) + m.populateImports(ctx, t.Params().At(i).Type(), imports) } for i := 0; i < t.Results().Len(); i++ { - m.populateImports(t.Results().At(i).Type(), imports) + m.populateImports(ctx, t.Results().At(i).Type(), imports) } case *types.Map: - m.populateImports(t.Key(), imports) - m.populateImports(t.Elem(), imports) + m.populateImports(ctx, t.Key(), imports) + m.populateImports(ctx, t.Elem(), imports) case *types.Chan: - m.populateImports(t.Elem(), imports) + m.populateImports(ctx, t.Elem(), imports) case *types.Pointer: - m.populateImports(t.Elem(), imports) + m.populateImports(ctx, t.Elem(), imports) case *types.Struct: // anonymous struct for i := 0; i < t.NumFields(); i++ { - m.populateImports(t.Field(i).Type(), imports) + m.populateImports(ctx, t.Field(i).Type(), imports) } case *types.Interface: // anonymous interface for i := 0; i < t.NumExplicitMethods(); i++ { - m.populateImports(t.ExplicitMethod(i).Type(), imports) + m.populateImports(ctx, t.ExplicitMethod(i).Type(), imports) } for i := 0; i < t.NumEmbeddeds(); i++ { - m.populateImports(t.EmbeddedType(i), imports) + m.populateImports(ctx, t.EmbeddedType(i), imports) } } } diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index b55c5635..1e96566b 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -1,6 +1,7 @@ package registry import ( + "context" "errors" "fmt" "go/ast" @@ -8,6 +9,7 @@ import ( "sort" "strings" + "github.com/rs/zerolog" "golang.org/x/tools/go/packages" ) @@ -77,8 +79,10 @@ func (r *Registry) MethodScope() *MethodScope { // AddImport adds the given package to the set of imports. It generates a // suitable alias if there are any conflicts with previously imported // packages. -func (r *Registry) AddImport(pkg *types.Package) *Package { +func (r *Registry) AddImport(ctx context.Context, pkg *types.Package) *Package { + log := zerolog.Ctx(ctx) path := pkg.Path() + log.Debug().Str("method", "AddImport").Str("src-pkg-path", path).Str("dst-pkg", r.dstPkg).Msg("adding import") if path == r.dstPkg { return nil } From f0de03c86b293970b9cca043cc986952a8b8833f Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 13:28:30 -0600 Subject: [PATCH 43/50] Change name of moq mocks --- .mockery-moq.yaml | 15 +- Taskfile.yml | 2 +- .../vektra/mockery/v2/pkg/fixtures/A.go | 79 ----- .../mockery/v2/pkg/fixtures/AsyncProducer.go | 173 ---------- .../vektra/mockery/v2/pkg/fixtures/Blank.go | 84 ----- .../mockery/v2/pkg/fixtures/ConsulLock.go | 132 -------- .../mockery/v2/pkg/fixtures/EmbeddedGet.go | 79 ----- .../vektra/mockery/v2/pkg/fixtures/Example.go | 135 -------- .../mockery/v2/pkg/fixtures/Expecter.go | 315 ------------------ .../vektra/mockery/v2/pkg/fixtures/Fooer.go | 194 ----------- .../v2/pkg/fixtures/FuncArgsCollision.go | 84 ----- .../mockery/v2/pkg/fixtures/GetGeneric.go | 79 ----- .../vektra/mockery/v2/pkg/fixtures/GetInt.go | 77 ----- .../fixtures/HasConflictingNestedImports.go | 135 -------- .../v2/pkg/fixtures/ImportsSameAsPackage.go | 183 ---------- .../mockery/v2/pkg/fixtures/KeyManager.go | 92 ----- .../vektra/mockery/v2/pkg/fixtures/MapFunc.go | 84 ----- .../mockery/v2/pkg/fixtures/MapToInterface.go | 84 ----- .../mockery/v2/pkg/fixtures/MyReader.go | 84 ----- .../v2/pkg/fixtures/PanicOnNoReturnValue.go | 77 ----- .../mockery/v2/pkg/fixtures/Requester.go | 84 ----- .../mockery/v2/pkg/fixtures/Requester2.go | 84 ----- .../mockery/v2/pkg/fixtures/Requester3.go | 77 ----- .../mockery/v2/pkg/fixtures/Requester4.go | 77 ----- .../pkg/fixtures/RequesterArgSameAsImport.go | 85 ----- .../fixtures/RequesterArgSameAsNamedImport.go | 85 ----- .../v2/pkg/fixtures/RequesterArgSameAsPkg.go | 84 ----- .../mockery/v2/pkg/fixtures/RequesterArray.go | 84 ----- .../v2/pkg/fixtures/RequesterElided.go | 90 ----- .../mockery/v2/pkg/fixtures/RequesterIface.go | 78 ----- .../mockery/v2/pkg/fixtures/RequesterNS.go | 85 ----- .../mockery/v2/pkg/fixtures/RequesterPtr.go | 84 ----- .../v2/pkg/fixtures/RequesterReturnElided.go | 139 -------- .../mockery/v2/pkg/fixtures/RequesterSlice.go | 84 ----- .../v2/pkg/fixtures/RequesterVariadic.go | 262 --------------- .../vektra/mockery/v2/pkg/fixtures/Sibling.go | 77 ----- .../mockery/v2/pkg/fixtures/StructWithTag.go | 108 ------ .../v2/pkg/fixtures/UsesOtherPkgIface.go | 86 ----- .../mockery/v2/pkg/fixtures/Variadic.go | 90 ----- .../pkg/fixtures/VariadicNoReturnInterface.go | 90 ----- .../v2/pkg/fixtures/VariadicReturnFunc.go | 84 ----- 41 files changed, 11 insertions(+), 4193 deletions(-) delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go delete mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 0d44a9b5..5f4eb1c8 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -1,17 +1,22 @@ quiet: False disable-version-string: True -with-expecter: True -mockname: "{{.InterfaceName}}Mock" -filename: "{{.InterfaceName}}.go" +mockname: "{{.InterfaceName}}Moq" +filename: "{{.InterfaceName | snakecase }}_moq.go" dir: "mocks/moq/{{.PackagePath}}" +style: moq packages: github.com/vektra/mockery/v2/pkg/fixtures: config: include-regex: '.*' exclude-regex: 'RequesterGenerics|UnsafeInterface|requester_unexported' - style: moq outpkg: test template-map: with-resets: true - skip-ensure: true + skip-ensure: false stub-impl: false + github.com/vektra/mockery/v2/pkg/fixtures/inpackage: + config: + dir: "{{.InterfaceDir}}" + all: True + outpkg: "{{.PackageName}}" + \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index cc4a2b12..ece03e57 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,7 +21,7 @@ tasks: mocks.remove: desc: remove all mock files cmds: - - find . -name '*_mock.go' | xargs rm + - find . -name '*_mock.go' -o -name '*_moq.go' | xargs rm - rm -rf mocks/ mocks.generate: diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go deleted file mode 100644 index cb35a530..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/A.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" -) - -// AMock is a mock implementation of A. -// -// func TestSomethingThatUsesA(t *testing.T) { -// -// // make and configure a mocked A -// mockedA := &AMock{ -// CallFunc: func() (test.B, error) { -// panic("mock out the Call method") -// }, -// } -// -// // use mockedA in code that requires A -// // and then make assertions. -// -// } -type AMock struct { - // CallFunc mocks the Call method. - CallFunc func() (test.B, error) - - // calls tracks calls to the methods. - calls struct { - // Call holds details about calls to the Call method. - Call []struct { - } - } - lockCall sync.RWMutex -} - -// Call calls CallFunc. -func (mock *AMock) Call() (test.B, error) { - if mock.CallFunc == nil { - panic("AMock.CallFunc: method is nil but A.Call was just called") - } - callInfo := struct { - }{} - mock.lockCall.Lock() - mock.calls.Call = append(mock.calls.Call, callInfo) - mock.lockCall.Unlock() - return mock.CallFunc() -} - -// CallCalls gets all the calls that were made to Call. -// Check the length with: -// -// len(mockedA.CallCalls()) -func (mock *AMock) CallCalls() []struct { -} { - var calls []struct { - } - mock.lockCall.RLock() - calls = mock.calls.Call - mock.lockCall.RUnlock() - return calls -} - -// ResetCallCalls reset all the calls that were made to Call. -func (mock *AMock) ResetCallCalls() { - mock.lockCall.Lock() - mock.calls.Call = nil - mock.lockCall.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *AMock) ResetCalls() { - mock.lockCall.Lock() - mock.calls.Call = nil - mock.lockCall.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go deleted file mode 100644 index b1a95585..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/AsyncProducer.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// AsyncProducerMock is a mock implementation of AsyncProducer. -// -// func TestSomethingThatUsesAsyncProducer(t *testing.T) { -// -// // make and configure a mocked AsyncProducer -// mockedAsyncProducer := &AsyncProducerMock{ -// InputFunc: func() chan<- bool { -// panic("mock out the Input method") -// }, -// OutputFunc: func() <-chan bool { -// panic("mock out the Output method") -// }, -// WhateverFunc: func() chan bool { -// panic("mock out the Whatever method") -// }, -// } -// -// // use mockedAsyncProducer in code that requires AsyncProducer -// // and then make assertions. -// -// } -type AsyncProducerMock struct { - // InputFunc mocks the Input method. - InputFunc func() chan<- bool - - // OutputFunc mocks the Output method. - OutputFunc func() <-chan bool - - // WhateverFunc mocks the Whatever method. - WhateverFunc func() chan bool - - // calls tracks calls to the methods. - calls struct { - // Input holds details about calls to the Input method. - Input []struct { - } - // Output holds details about calls to the Output method. - Output []struct { - } - // Whatever holds details about calls to the Whatever method. - Whatever []struct { - } - } - lockInput sync.RWMutex - lockOutput sync.RWMutex - lockWhatever sync.RWMutex -} - -// Input calls InputFunc. -func (mock *AsyncProducerMock) Input() chan<- bool { - if mock.InputFunc == nil { - panic("AsyncProducerMock.InputFunc: method is nil but AsyncProducer.Input was just called") - } - callInfo := struct { - }{} - mock.lockInput.Lock() - mock.calls.Input = append(mock.calls.Input, callInfo) - mock.lockInput.Unlock() - return mock.InputFunc() -} - -// InputCalls gets all the calls that were made to Input. -// Check the length with: -// -// len(mockedAsyncProducer.InputCalls()) -func (mock *AsyncProducerMock) InputCalls() []struct { -} { - var calls []struct { - } - mock.lockInput.RLock() - calls = mock.calls.Input - mock.lockInput.RUnlock() - return calls -} - -// ResetInputCalls reset all the calls that were made to Input. -func (mock *AsyncProducerMock) ResetInputCalls() { - mock.lockInput.Lock() - mock.calls.Input = nil - mock.lockInput.Unlock() -} - -// Output calls OutputFunc. -func (mock *AsyncProducerMock) Output() <-chan bool { - if mock.OutputFunc == nil { - panic("AsyncProducerMock.OutputFunc: method is nil but AsyncProducer.Output was just called") - } - callInfo := struct { - }{} - mock.lockOutput.Lock() - mock.calls.Output = append(mock.calls.Output, callInfo) - mock.lockOutput.Unlock() - return mock.OutputFunc() -} - -// OutputCalls gets all the calls that were made to Output. -// Check the length with: -// -// len(mockedAsyncProducer.OutputCalls()) -func (mock *AsyncProducerMock) OutputCalls() []struct { -} { - var calls []struct { - } - mock.lockOutput.RLock() - calls = mock.calls.Output - mock.lockOutput.RUnlock() - return calls -} - -// ResetOutputCalls reset all the calls that were made to Output. -func (mock *AsyncProducerMock) ResetOutputCalls() { - mock.lockOutput.Lock() - mock.calls.Output = nil - mock.lockOutput.Unlock() -} - -// Whatever calls WhateverFunc. -func (mock *AsyncProducerMock) Whatever() chan bool { - if mock.WhateverFunc == nil { - panic("AsyncProducerMock.WhateverFunc: method is nil but AsyncProducer.Whatever was just called") - } - callInfo := struct { - }{} - mock.lockWhatever.Lock() - mock.calls.Whatever = append(mock.calls.Whatever, callInfo) - mock.lockWhatever.Unlock() - return mock.WhateverFunc() -} - -// WhateverCalls gets all the calls that were made to Whatever. -// Check the length with: -// -// len(mockedAsyncProducer.WhateverCalls()) -func (mock *AsyncProducerMock) WhateverCalls() []struct { -} { - var calls []struct { - } - mock.lockWhatever.RLock() - calls = mock.calls.Whatever - mock.lockWhatever.RUnlock() - return calls -} - -// ResetWhateverCalls reset all the calls that were made to Whatever. -func (mock *AsyncProducerMock) ResetWhateverCalls() { - mock.lockWhatever.Lock() - mock.calls.Whatever = nil - mock.lockWhatever.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *AsyncProducerMock) ResetCalls() { - mock.lockInput.Lock() - mock.calls.Input = nil - mock.lockInput.Unlock() - - mock.lockOutput.Lock() - mock.calls.Output = nil - mock.lockOutput.Unlock() - - mock.lockWhatever.Lock() - mock.calls.Whatever = nil - mock.lockWhatever.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go deleted file mode 100644 index d32c77d1..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Blank.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// BlankMock is a mock implementation of Blank. -// -// func TestSomethingThatUsesBlank(t *testing.T) { -// -// // make and configure a mocked Blank -// mockedBlank := &BlankMock{ -// CreateFunc: func(x interface{}) error { -// panic("mock out the Create method") -// }, -// } -// -// // use mockedBlank in code that requires Blank -// // and then make assertions. -// -// } -type BlankMock struct { - // CreateFunc mocks the Create method. - CreateFunc func(x interface{}) error - - // calls tracks calls to the methods. - calls struct { - // Create holds details about calls to the Create method. - Create []struct { - // X is the x argument value. - X interface{} - } - } - lockCreate sync.RWMutex -} - -// Create calls CreateFunc. -func (mock *BlankMock) Create(x interface{}) error { - if mock.CreateFunc == nil { - panic("BlankMock.CreateFunc: method is nil but Blank.Create was just called") - } - callInfo := struct { - X interface{} - }{ - X: x, - } - mock.lockCreate.Lock() - mock.calls.Create = append(mock.calls.Create, callInfo) - mock.lockCreate.Unlock() - return mock.CreateFunc(x) -} - -// CreateCalls gets all the calls that were made to Create. -// Check the length with: -// -// len(mockedBlank.CreateCalls()) -func (mock *BlankMock) CreateCalls() []struct { - X interface{} -} { - var calls []struct { - X interface{} - } - mock.lockCreate.RLock() - calls = mock.calls.Create - mock.lockCreate.RUnlock() - return calls -} - -// ResetCreateCalls reset all the calls that were made to Create. -func (mock *BlankMock) ResetCreateCalls() { - mock.lockCreate.Lock() - mock.calls.Create = nil - mock.lockCreate.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *BlankMock) ResetCalls() { - mock.lockCreate.Lock() - mock.calls.Create = nil - mock.lockCreate.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go deleted file mode 100644 index 66abf534..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ConsulLock.go +++ /dev/null @@ -1,132 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// ConsulLockMock is a mock implementation of ConsulLock. -// -// func TestSomethingThatUsesConsulLock(t *testing.T) { -// -// // make and configure a mocked ConsulLock -// mockedConsulLock := &ConsulLockMock{ -// LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { -// panic("mock out the Lock method") -// }, -// UnlockFunc: func() error { -// panic("mock out the Unlock method") -// }, -// } -// -// // use mockedConsulLock in code that requires ConsulLock -// // and then make assertions. -// -// } -type ConsulLockMock struct { - // LockFunc mocks the Lock method. - LockFunc func(valCh <-chan struct{}) (<-chan struct{}, error) - - // UnlockFunc mocks the Unlock method. - UnlockFunc func() error - - // calls tracks calls to the methods. - calls struct { - // Lock holds details about calls to the Lock method. - Lock []struct { - // ValCh is the valCh argument value. - ValCh <-chan struct{} - } - // Unlock holds details about calls to the Unlock method. - Unlock []struct { - } - } - lockLock sync.RWMutex - lockUnlock sync.RWMutex -} - -// Lock calls LockFunc. -func (mock *ConsulLockMock) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { - if mock.LockFunc == nil { - panic("ConsulLockMock.LockFunc: method is nil but ConsulLock.Lock was just called") - } - callInfo := struct { - ValCh <-chan struct{} - }{ - ValCh: valCh, - } - mock.lockLock.Lock() - mock.calls.Lock = append(mock.calls.Lock, callInfo) - mock.lockLock.Unlock() - return mock.LockFunc(valCh) -} - -// LockCalls gets all the calls that were made to Lock. -// Check the length with: -// -// len(mockedConsulLock.LockCalls()) -func (mock *ConsulLockMock) LockCalls() []struct { - ValCh <-chan struct{} -} { - var calls []struct { - ValCh <-chan struct{} - } - mock.lockLock.RLock() - calls = mock.calls.Lock - mock.lockLock.RUnlock() - return calls -} - -// ResetLockCalls reset all the calls that were made to Lock. -func (mock *ConsulLockMock) ResetLockCalls() { - mock.lockLock.Lock() - mock.calls.Lock = nil - mock.lockLock.Unlock() -} - -// Unlock calls UnlockFunc. -func (mock *ConsulLockMock) Unlock() error { - if mock.UnlockFunc == nil { - panic("ConsulLockMock.UnlockFunc: method is nil but ConsulLock.Unlock was just called") - } - callInfo := struct { - }{} - mock.lockUnlock.Lock() - mock.calls.Unlock = append(mock.calls.Unlock, callInfo) - mock.lockUnlock.Unlock() - return mock.UnlockFunc() -} - -// UnlockCalls gets all the calls that were made to Unlock. -// Check the length with: -// -// len(mockedConsulLock.UnlockCalls()) -func (mock *ConsulLockMock) UnlockCalls() []struct { -} { - var calls []struct { - } - mock.lockUnlock.RLock() - calls = mock.calls.Unlock - mock.lockUnlock.RUnlock() - return calls -} - -// ResetUnlockCalls reset all the calls that were made to Unlock. -func (mock *ConsulLockMock) ResetUnlockCalls() { - mock.lockUnlock.Lock() - mock.calls.Unlock = nil - mock.lockUnlock.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ConsulLockMock) ResetCalls() { - mock.lockLock.Lock() - mock.calls.Lock = nil - mock.lockLock.Unlock() - - mock.lockUnlock.Lock() - mock.calls.Unlock = nil - mock.lockUnlock.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go deleted file mode 100644 index 41d69d69..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/EmbeddedGet.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - "github.com/vektra/mockery/v2/pkg/fixtures/constraints" -) - -// EmbeddedGetMock is a mock implementation of EmbeddedGet. -// -// func TestSomethingThatUsesEmbeddedGet(t *testing.T) { -// -// // make and configure a mocked EmbeddedGet -// mockedEmbeddedGet := &EmbeddedGetMock{ -// GetFunc: func() T { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedEmbeddedGet in code that requires EmbeddedGet -// // and then make assertions. -// -// } -type EmbeddedGetMock[T constraints.Signed] struct { - // GetFunc mocks the Get method. - GetFunc func() T - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *EmbeddedGetMock[T]) Get() T { - if mock.GetFunc == nil { - panic("EmbeddedGetMock.GetFunc: method is nil but EmbeddedGet.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedEmbeddedGet.GetCalls()) -func (mock *EmbeddedGetMock[T]) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *EmbeddedGetMock[T]) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *EmbeddedGetMock[T]) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go deleted file mode 100644 index 343150d8..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Example.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "net/http" - "sync" - - my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" -) - -// ExampleMock is a mock implementation of Example. -// -// func TestSomethingThatUsesExample(t *testing.T) { -// -// // make and configure a mocked Example -// mockedExample := &ExampleMock{ -// AFunc: func() http.Flusher { -// panic("mock out the A method") -// }, -// BFunc: func(fixtureshttp string) my_http.MyStruct { -// panic("mock out the B method") -// }, -// } -// -// // use mockedExample in code that requires Example -// // and then make assertions. -// -// } -type ExampleMock struct { - // AFunc mocks the A method. - AFunc func() http.Flusher - - // BFunc mocks the B method. - BFunc func(fixtureshttp string) my_http.MyStruct - - // calls tracks calls to the methods. - calls struct { - // A holds details about calls to the A method. - A []struct { - } - // B holds details about calls to the B method. - B []struct { - // Fixtureshttp is the fixtureshttp argument value. - Fixtureshttp string - } - } - lockA sync.RWMutex - lockB sync.RWMutex -} - -// A calls AFunc. -func (mock *ExampleMock) A() http.Flusher { - if mock.AFunc == nil { - panic("ExampleMock.AFunc: method is nil but Example.A was just called") - } - callInfo := struct { - }{} - mock.lockA.Lock() - mock.calls.A = append(mock.calls.A, callInfo) - mock.lockA.Unlock() - return mock.AFunc() -} - -// ACalls gets all the calls that were made to A. -// Check the length with: -// -// len(mockedExample.ACalls()) -func (mock *ExampleMock) ACalls() []struct { -} { - var calls []struct { - } - mock.lockA.RLock() - calls = mock.calls.A - mock.lockA.RUnlock() - return calls -} - -// ResetACalls reset all the calls that were made to A. -func (mock *ExampleMock) ResetACalls() { - mock.lockA.Lock() - mock.calls.A = nil - mock.lockA.Unlock() -} - -// B calls BFunc. -func (mock *ExampleMock) B(fixtureshttp string) my_http.MyStruct { - if mock.BFunc == nil { - panic("ExampleMock.BFunc: method is nil but Example.B was just called") - } - callInfo := struct { - Fixtureshttp string - }{ - Fixtureshttp: fixtureshttp, - } - mock.lockB.Lock() - mock.calls.B = append(mock.calls.B, callInfo) - mock.lockB.Unlock() - return mock.BFunc(fixtureshttp) -} - -// BCalls gets all the calls that were made to B. -// Check the length with: -// -// len(mockedExample.BCalls()) -func (mock *ExampleMock) BCalls() []struct { - Fixtureshttp string -} { - var calls []struct { - Fixtureshttp string - } - mock.lockB.RLock() - calls = mock.calls.B - mock.lockB.RUnlock() - return calls -} - -// ResetBCalls reset all the calls that were made to B. -func (mock *ExampleMock) ResetBCalls() { - mock.lockB.Lock() - mock.calls.B = nil - mock.lockB.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ExampleMock) ResetCalls() { - mock.lockA.Lock() - mock.calls.A = nil - mock.lockA.Unlock() - - mock.lockB.Lock() - mock.calls.B = nil - mock.lockB.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go deleted file mode 100644 index 9e3dce15..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Expecter.go +++ /dev/null @@ -1,315 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// ExpecterMock is a mock implementation of Expecter. -// -// func TestSomethingThatUsesExpecter(t *testing.T) { -// -// // make and configure a mocked Expecter -// mockedExpecter := &ExpecterMock{ -// ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { -// panic("mock out the ManyArgsReturns method") -// }, -// NoArgFunc: func() string { -// panic("mock out the NoArg method") -// }, -// NoReturnFunc: func(str string) { -// panic("mock out the NoReturn method") -// }, -// VariadicFunc: func(ints ...int) error { -// panic("mock out the Variadic method") -// }, -// VariadicManyFunc: func(i int, a string, intfs ...interface{}) error { -// panic("mock out the VariadicMany method") -// }, -// } -// -// // use mockedExpecter in code that requires Expecter -// // and then make assertions. -// -// } -type ExpecterMock struct { - // ManyArgsReturnsFunc mocks the ManyArgsReturns method. - ManyArgsReturnsFunc func(str string, i int) ([]string, error) - - // NoArgFunc mocks the NoArg method. - NoArgFunc func() string - - // NoReturnFunc mocks the NoReturn method. - NoReturnFunc func(str string) - - // VariadicFunc mocks the Variadic method. - VariadicFunc func(ints ...int) error - - // VariadicManyFunc mocks the VariadicMany method. - VariadicManyFunc func(i int, a string, intfs ...interface{}) error - - // calls tracks calls to the methods. - calls struct { - // ManyArgsReturns holds details about calls to the ManyArgsReturns method. - ManyArgsReturns []struct { - // Str is the str argument value. - Str string - // I is the i argument value. - I int - } - // NoArg holds details about calls to the NoArg method. - NoArg []struct { - } - // NoReturn holds details about calls to the NoReturn method. - NoReturn []struct { - // Str is the str argument value. - Str string - } - // Variadic holds details about calls to the Variadic method. - Variadic []struct { - // Ints is the ints argument value. - Ints []int - } - // VariadicMany holds details about calls to the VariadicMany method. - VariadicMany []struct { - // I is the i argument value. - I int - // A is the a argument value. - A string - // Intfs is the intfs argument value. - Intfs []interface{} - } - } - lockManyArgsReturns sync.RWMutex - lockNoArg sync.RWMutex - lockNoReturn sync.RWMutex - lockVariadic sync.RWMutex - lockVariadicMany sync.RWMutex -} - -// ManyArgsReturns calls ManyArgsReturnsFunc. -func (mock *ExpecterMock) ManyArgsReturns(str string, i int) ([]string, error) { - if mock.ManyArgsReturnsFunc == nil { - panic("ExpecterMock.ManyArgsReturnsFunc: method is nil but Expecter.ManyArgsReturns was just called") - } - callInfo := struct { - Str string - I int - }{ - Str: str, - I: i, - } - mock.lockManyArgsReturns.Lock() - mock.calls.ManyArgsReturns = append(mock.calls.ManyArgsReturns, callInfo) - mock.lockManyArgsReturns.Unlock() - return mock.ManyArgsReturnsFunc(str, i) -} - -// ManyArgsReturnsCalls gets all the calls that were made to ManyArgsReturns. -// Check the length with: -// -// len(mockedExpecter.ManyArgsReturnsCalls()) -func (mock *ExpecterMock) ManyArgsReturnsCalls() []struct { - Str string - I int -} { - var calls []struct { - Str string - I int - } - mock.lockManyArgsReturns.RLock() - calls = mock.calls.ManyArgsReturns - mock.lockManyArgsReturns.RUnlock() - return calls -} - -// ResetManyArgsReturnsCalls reset all the calls that were made to ManyArgsReturns. -func (mock *ExpecterMock) ResetManyArgsReturnsCalls() { - mock.lockManyArgsReturns.Lock() - mock.calls.ManyArgsReturns = nil - mock.lockManyArgsReturns.Unlock() -} - -// NoArg calls NoArgFunc. -func (mock *ExpecterMock) NoArg() string { - if mock.NoArgFunc == nil { - panic("ExpecterMock.NoArgFunc: method is nil but Expecter.NoArg was just called") - } - callInfo := struct { - }{} - mock.lockNoArg.Lock() - mock.calls.NoArg = append(mock.calls.NoArg, callInfo) - mock.lockNoArg.Unlock() - return mock.NoArgFunc() -} - -// NoArgCalls gets all the calls that were made to NoArg. -// Check the length with: -// -// len(mockedExpecter.NoArgCalls()) -func (mock *ExpecterMock) NoArgCalls() []struct { -} { - var calls []struct { - } - mock.lockNoArg.RLock() - calls = mock.calls.NoArg - mock.lockNoArg.RUnlock() - return calls -} - -// ResetNoArgCalls reset all the calls that were made to NoArg. -func (mock *ExpecterMock) ResetNoArgCalls() { - mock.lockNoArg.Lock() - mock.calls.NoArg = nil - mock.lockNoArg.Unlock() -} - -// NoReturn calls NoReturnFunc. -func (mock *ExpecterMock) NoReturn(str string) { - if mock.NoReturnFunc == nil { - panic("ExpecterMock.NoReturnFunc: method is nil but Expecter.NoReturn was just called") - } - callInfo := struct { - Str string - }{ - Str: str, - } - mock.lockNoReturn.Lock() - mock.calls.NoReturn = append(mock.calls.NoReturn, callInfo) - mock.lockNoReturn.Unlock() - mock.NoReturnFunc(str) -} - -// NoReturnCalls gets all the calls that were made to NoReturn. -// Check the length with: -// -// len(mockedExpecter.NoReturnCalls()) -func (mock *ExpecterMock) NoReturnCalls() []struct { - Str string -} { - var calls []struct { - Str string - } - mock.lockNoReturn.RLock() - calls = mock.calls.NoReturn - mock.lockNoReturn.RUnlock() - return calls -} - -// ResetNoReturnCalls reset all the calls that were made to NoReturn. -func (mock *ExpecterMock) ResetNoReturnCalls() { - mock.lockNoReturn.Lock() - mock.calls.NoReturn = nil - mock.lockNoReturn.Unlock() -} - -// Variadic calls VariadicFunc. -func (mock *ExpecterMock) Variadic(ints ...int) error { - if mock.VariadicFunc == nil { - panic("ExpecterMock.VariadicFunc: method is nil but Expecter.Variadic was just called") - } - callInfo := struct { - Ints []int - }{ - Ints: ints, - } - mock.lockVariadic.Lock() - mock.calls.Variadic = append(mock.calls.Variadic, callInfo) - mock.lockVariadic.Unlock() - return mock.VariadicFunc(ints...) -} - -// VariadicCalls gets all the calls that were made to Variadic. -// Check the length with: -// -// len(mockedExpecter.VariadicCalls()) -func (mock *ExpecterMock) VariadicCalls() []struct { - Ints []int -} { - var calls []struct { - Ints []int - } - mock.lockVariadic.RLock() - calls = mock.calls.Variadic - mock.lockVariadic.RUnlock() - return calls -} - -// ResetVariadicCalls reset all the calls that were made to Variadic. -func (mock *ExpecterMock) ResetVariadicCalls() { - mock.lockVariadic.Lock() - mock.calls.Variadic = nil - mock.lockVariadic.Unlock() -} - -// VariadicMany calls VariadicManyFunc. -func (mock *ExpecterMock) VariadicMany(i int, a string, intfs ...interface{}) error { - if mock.VariadicManyFunc == nil { - panic("ExpecterMock.VariadicManyFunc: method is nil but Expecter.VariadicMany was just called") - } - callInfo := struct { - I int - A string - Intfs []interface{} - }{ - I: i, - A: a, - Intfs: intfs, - } - mock.lockVariadicMany.Lock() - mock.calls.VariadicMany = append(mock.calls.VariadicMany, callInfo) - mock.lockVariadicMany.Unlock() - return mock.VariadicManyFunc(i, a, intfs...) -} - -// VariadicManyCalls gets all the calls that were made to VariadicMany. -// Check the length with: -// -// len(mockedExpecter.VariadicManyCalls()) -func (mock *ExpecterMock) VariadicManyCalls() []struct { - I int - A string - Intfs []interface{} -} { - var calls []struct { - I int - A string - Intfs []interface{} - } - mock.lockVariadicMany.RLock() - calls = mock.calls.VariadicMany - mock.lockVariadicMany.RUnlock() - return calls -} - -// ResetVariadicManyCalls reset all the calls that were made to VariadicMany. -func (mock *ExpecterMock) ResetVariadicManyCalls() { - mock.lockVariadicMany.Lock() - mock.calls.VariadicMany = nil - mock.lockVariadicMany.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ExpecterMock) ResetCalls() { - mock.lockManyArgsReturns.Lock() - mock.calls.ManyArgsReturns = nil - mock.lockManyArgsReturns.Unlock() - - mock.lockNoArg.Lock() - mock.calls.NoArg = nil - mock.lockNoArg.Unlock() - - mock.lockNoReturn.Lock() - mock.calls.NoReturn = nil - mock.lockNoReturn.Unlock() - - mock.lockVariadic.Lock() - mock.calls.Variadic = nil - mock.lockVariadic.Unlock() - - mock.lockVariadicMany.Lock() - mock.calls.VariadicMany = nil - mock.lockVariadicMany.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go deleted file mode 100644 index 1e5915bd..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Fooer.go +++ /dev/null @@ -1,194 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// FooerMock is a mock implementation of Fooer. -// -// func TestSomethingThatUsesFooer(t *testing.T) { -// -// // make and configure a mocked Fooer -// mockedFooer := &FooerMock{ -// BarFunc: func(f func([]int)) { -// panic("mock out the Bar method") -// }, -// BazFunc: func(path string) func(x string) string { -// panic("mock out the Baz method") -// }, -// FooFunc: func(f func(x string) string) error { -// panic("mock out the Foo method") -// }, -// } -// -// // use mockedFooer in code that requires Fooer -// // and then make assertions. -// -// } -type FooerMock struct { - // BarFunc mocks the Bar method. - BarFunc func(f func([]int)) - - // BazFunc mocks the Baz method. - BazFunc func(path string) func(x string) string - - // FooFunc mocks the Foo method. - FooFunc func(f func(x string) string) error - - // calls tracks calls to the methods. - calls struct { - // Bar holds details about calls to the Bar method. - Bar []struct { - // F is the f argument value. - F func([]int) - } - // Baz holds details about calls to the Baz method. - Baz []struct { - // Path is the path argument value. - Path string - } - // Foo holds details about calls to the Foo method. - Foo []struct { - // F is the f argument value. - F func(x string) string - } - } - lockBar sync.RWMutex - lockBaz sync.RWMutex - lockFoo sync.RWMutex -} - -// Bar calls BarFunc. -func (mock *FooerMock) Bar(f func([]int)) { - if mock.BarFunc == nil { - panic("FooerMock.BarFunc: method is nil but Fooer.Bar was just called") - } - callInfo := struct { - F func([]int) - }{ - F: f, - } - mock.lockBar.Lock() - mock.calls.Bar = append(mock.calls.Bar, callInfo) - mock.lockBar.Unlock() - mock.BarFunc(f) -} - -// BarCalls gets all the calls that were made to Bar. -// Check the length with: -// -// len(mockedFooer.BarCalls()) -func (mock *FooerMock) BarCalls() []struct { - F func([]int) -} { - var calls []struct { - F func([]int) - } - mock.lockBar.RLock() - calls = mock.calls.Bar - mock.lockBar.RUnlock() - return calls -} - -// ResetBarCalls reset all the calls that were made to Bar. -func (mock *FooerMock) ResetBarCalls() { - mock.lockBar.Lock() - mock.calls.Bar = nil - mock.lockBar.Unlock() -} - -// Baz calls BazFunc. -func (mock *FooerMock) Baz(path string) func(x string) string { - if mock.BazFunc == nil { - panic("FooerMock.BazFunc: method is nil but Fooer.Baz was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockBaz.Lock() - mock.calls.Baz = append(mock.calls.Baz, callInfo) - mock.lockBaz.Unlock() - return mock.BazFunc(path) -} - -// BazCalls gets all the calls that were made to Baz. -// Check the length with: -// -// len(mockedFooer.BazCalls()) -func (mock *FooerMock) BazCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockBaz.RLock() - calls = mock.calls.Baz - mock.lockBaz.RUnlock() - return calls -} - -// ResetBazCalls reset all the calls that were made to Baz. -func (mock *FooerMock) ResetBazCalls() { - mock.lockBaz.Lock() - mock.calls.Baz = nil - mock.lockBaz.Unlock() -} - -// Foo calls FooFunc. -func (mock *FooerMock) Foo(f func(x string) string) error { - if mock.FooFunc == nil { - panic("FooerMock.FooFunc: method is nil but Fooer.Foo was just called") - } - callInfo := struct { - F func(x string) string - }{ - F: f, - } - mock.lockFoo.Lock() - mock.calls.Foo = append(mock.calls.Foo, callInfo) - mock.lockFoo.Unlock() - return mock.FooFunc(f) -} - -// FooCalls gets all the calls that were made to Foo. -// Check the length with: -// -// len(mockedFooer.FooCalls()) -func (mock *FooerMock) FooCalls() []struct { - F func(x string) string -} { - var calls []struct { - F func(x string) string - } - mock.lockFoo.RLock() - calls = mock.calls.Foo - mock.lockFoo.RUnlock() - return calls -} - -// ResetFooCalls reset all the calls that were made to Foo. -func (mock *FooerMock) ResetFooCalls() { - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *FooerMock) ResetCalls() { - mock.lockBar.Lock() - mock.calls.Bar = nil - mock.lockBar.Unlock() - - mock.lockBaz.Lock() - mock.calls.Baz = nil - mock.lockBaz.Unlock() - - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go deleted file mode 100644 index 8b158e73..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/FuncArgsCollision.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// FuncArgsCollisionMock is a mock implementation of FuncArgsCollision. -// -// func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { -// -// // make and configure a mocked FuncArgsCollision -// mockedFuncArgsCollision := &FuncArgsCollisionMock{ -// FooFunc: func(ret interface{}) error { -// panic("mock out the Foo method") -// }, -// } -// -// // use mockedFuncArgsCollision in code that requires FuncArgsCollision -// // and then make assertions. -// -// } -type FuncArgsCollisionMock struct { - // FooFunc mocks the Foo method. - FooFunc func(ret interface{}) error - - // calls tracks calls to the methods. - calls struct { - // Foo holds details about calls to the Foo method. - Foo []struct { - // Ret is the ret argument value. - Ret interface{} - } - } - lockFoo sync.RWMutex -} - -// Foo calls FooFunc. -func (mock *FuncArgsCollisionMock) Foo(ret interface{}) error { - if mock.FooFunc == nil { - panic("FuncArgsCollisionMock.FooFunc: method is nil but FuncArgsCollision.Foo was just called") - } - callInfo := struct { - Ret interface{} - }{ - Ret: ret, - } - mock.lockFoo.Lock() - mock.calls.Foo = append(mock.calls.Foo, callInfo) - mock.lockFoo.Unlock() - return mock.FooFunc(ret) -} - -// FooCalls gets all the calls that were made to Foo. -// Check the length with: -// -// len(mockedFuncArgsCollision.FooCalls()) -func (mock *FuncArgsCollisionMock) FooCalls() []struct { - Ret interface{} -} { - var calls []struct { - Ret interface{} - } - mock.lockFoo.RLock() - calls = mock.calls.Foo - mock.lockFoo.RUnlock() - return calls -} - -// ResetFooCalls reset all the calls that were made to Foo. -func (mock *FuncArgsCollisionMock) ResetFooCalls() { - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *FuncArgsCollisionMock) ResetCalls() { - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go deleted file mode 100644 index 8c44f575..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetGeneric.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - "github.com/vektra/mockery/v2/pkg/fixtures/constraints" -) - -// GetGenericMock is a mock implementation of GetGeneric. -// -// func TestSomethingThatUsesGetGeneric(t *testing.T) { -// -// // make and configure a mocked GetGeneric -// mockedGetGeneric := &GetGenericMock{ -// GetFunc: func() T { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedGetGeneric in code that requires GetGeneric -// // and then make assertions. -// -// } -type GetGenericMock[T constraints.Integer] struct { - // GetFunc mocks the Get method. - GetFunc func() T - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *GetGenericMock[T]) Get() T { - if mock.GetFunc == nil { - panic("GetGenericMock.GetFunc: method is nil but GetGeneric.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedGetGeneric.GetCalls()) -func (mock *GetGenericMock[T]) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *GetGenericMock[T]) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *GetGenericMock[T]) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go deleted file mode 100644 index ade38a64..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/GetInt.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// GetIntMock is a mock implementation of GetInt. -// -// func TestSomethingThatUsesGetInt(t *testing.T) { -// -// // make and configure a mocked GetInt -// mockedGetInt := &GetIntMock{ -// GetFunc: func() int { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedGetInt in code that requires GetInt -// // and then make assertions. -// -// } -type GetIntMock struct { - // GetFunc mocks the Get method. - GetFunc func() int - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *GetIntMock) Get() int { - if mock.GetFunc == nil { - panic("GetIntMock.GetFunc: method is nil but GetInt.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedGetInt.GetCalls()) -func (mock *GetIntMock) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *GetIntMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *GetIntMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go deleted file mode 100644 index de0a208a..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/HasConflictingNestedImports.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "net/http" - "sync" - - my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" -) - -// HasConflictingNestedImportsMock is a mock implementation of HasConflictingNestedImports. -// -// func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { -// -// // make and configure a mocked HasConflictingNestedImports -// mockedHasConflictingNestedImports := &HasConflictingNestedImportsMock{ -// GetFunc: func(path string) (http.Response, error) { -// panic("mock out the Get method") -// }, -// ZFunc: func() my_http.MyStruct { -// panic("mock out the Z method") -// }, -// } -// -// // use mockedHasConflictingNestedImports in code that requires HasConflictingNestedImports -// // and then make assertions. -// -// } -type HasConflictingNestedImportsMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (http.Response, error) - - // ZFunc mocks the Z method. - ZFunc func() my_http.MyStruct - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - // Z holds details about calls to the Z method. - Z []struct { - } - } - lockGet sync.RWMutex - lockZ sync.RWMutex -} - -// Get calls GetFunc. -func (mock *HasConflictingNestedImportsMock) Get(path string) (http.Response, error) { - if mock.GetFunc == nil { - panic("HasConflictingNestedImportsMock.GetFunc: method is nil but HasConflictingNestedImports.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedHasConflictingNestedImports.GetCalls()) -func (mock *HasConflictingNestedImportsMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *HasConflictingNestedImportsMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// Z calls ZFunc. -func (mock *HasConflictingNestedImportsMock) Z() my_http.MyStruct { - if mock.ZFunc == nil { - panic("HasConflictingNestedImportsMock.ZFunc: method is nil but HasConflictingNestedImports.Z was just called") - } - callInfo := struct { - }{} - mock.lockZ.Lock() - mock.calls.Z = append(mock.calls.Z, callInfo) - mock.lockZ.Unlock() - return mock.ZFunc() -} - -// ZCalls gets all the calls that were made to Z. -// Check the length with: -// -// len(mockedHasConflictingNestedImports.ZCalls()) -func (mock *HasConflictingNestedImportsMock) ZCalls() []struct { -} { - var calls []struct { - } - mock.lockZ.RLock() - calls = mock.calls.Z - mock.lockZ.RUnlock() - return calls -} - -// ResetZCalls reset all the calls that were made to Z. -func (mock *HasConflictingNestedImportsMock) ResetZCalls() { - mock.lockZ.Lock() - mock.calls.Z = nil - mock.lockZ.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *HasConflictingNestedImportsMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() - - mock.lockZ.Lock() - mock.calls.Z = nil - mock.lockZ.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go deleted file mode 100644 index 3774be2f..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/ImportsSameAsPackage.go +++ /dev/null @@ -1,183 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - fixtures "github.com/vektra/mockery/v2/pkg/fixtures" - redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" -) - -// ImportsSameAsPackageMock is a mock implementation of ImportsSameAsPackage. -// -// func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { -// -// // make and configure a mocked ImportsSameAsPackage -// mockedImportsSameAsPackage := &ImportsSameAsPackageMock{ -// AFunc: func() redefinedtypeb.B { -// panic("mock out the A method") -// }, -// BFunc: func() fixtures.KeyManager { -// panic("mock out the B method") -// }, -// CFunc: func(c fixtures.C) { -// panic("mock out the C method") -// }, -// } -// -// // use mockedImportsSameAsPackage in code that requires ImportsSameAsPackage -// // and then make assertions. -// -// } -type ImportsSameAsPackageMock struct { - // AFunc mocks the A method. - AFunc func() redefinedtypeb.B - - // BFunc mocks the B method. - BFunc func() fixtures.KeyManager - - // CFunc mocks the C method. - CFunc func(c fixtures.C) - - // calls tracks calls to the methods. - calls struct { - // A holds details about calls to the A method. - A []struct { - } - // B holds details about calls to the B method. - B []struct { - } - // C holds details about calls to the C method. - C []struct { - // C is the c argument value. - C fixtures.C - } - } - lockA sync.RWMutex - lockB sync.RWMutex - lockC sync.RWMutex -} - -// A calls AFunc. -func (mock *ImportsSameAsPackageMock) A() redefinedtypeb.B { - if mock.AFunc == nil { - panic("ImportsSameAsPackageMock.AFunc: method is nil but ImportsSameAsPackage.A was just called") - } - callInfo := struct { - }{} - mock.lockA.Lock() - mock.calls.A = append(mock.calls.A, callInfo) - mock.lockA.Unlock() - return mock.AFunc() -} - -// ACalls gets all the calls that were made to A. -// Check the length with: -// -// len(mockedImportsSameAsPackage.ACalls()) -func (mock *ImportsSameAsPackageMock) ACalls() []struct { -} { - var calls []struct { - } - mock.lockA.RLock() - calls = mock.calls.A - mock.lockA.RUnlock() - return calls -} - -// ResetACalls reset all the calls that were made to A. -func (mock *ImportsSameAsPackageMock) ResetACalls() { - mock.lockA.Lock() - mock.calls.A = nil - mock.lockA.Unlock() -} - -// B calls BFunc. -func (mock *ImportsSameAsPackageMock) B() fixtures.KeyManager { - if mock.BFunc == nil { - panic("ImportsSameAsPackageMock.BFunc: method is nil but ImportsSameAsPackage.B was just called") - } - callInfo := struct { - }{} - mock.lockB.Lock() - mock.calls.B = append(mock.calls.B, callInfo) - mock.lockB.Unlock() - return mock.BFunc() -} - -// BCalls gets all the calls that were made to B. -// Check the length with: -// -// len(mockedImportsSameAsPackage.BCalls()) -func (mock *ImportsSameAsPackageMock) BCalls() []struct { -} { - var calls []struct { - } - mock.lockB.RLock() - calls = mock.calls.B - mock.lockB.RUnlock() - return calls -} - -// ResetBCalls reset all the calls that were made to B. -func (mock *ImportsSameAsPackageMock) ResetBCalls() { - mock.lockB.Lock() - mock.calls.B = nil - mock.lockB.Unlock() -} - -// C calls CFunc. -func (mock *ImportsSameAsPackageMock) C(c fixtures.C) { - if mock.CFunc == nil { - panic("ImportsSameAsPackageMock.CFunc: method is nil but ImportsSameAsPackage.C was just called") - } - callInfo := struct { - C fixtures.C - }{ - C: c, - } - mock.lockC.Lock() - mock.calls.C = append(mock.calls.C, callInfo) - mock.lockC.Unlock() - mock.CFunc(c) -} - -// CCalls gets all the calls that were made to C. -// Check the length with: -// -// len(mockedImportsSameAsPackage.CCalls()) -func (mock *ImportsSameAsPackageMock) CCalls() []struct { - C fixtures.C -} { - var calls []struct { - C fixtures.C - } - mock.lockC.RLock() - calls = mock.calls.C - mock.lockC.RUnlock() - return calls -} - -// ResetCCalls reset all the calls that were made to C. -func (mock *ImportsSameAsPackageMock) ResetCCalls() { - mock.lockC.Lock() - mock.calls.C = nil - mock.lockC.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *ImportsSameAsPackageMock) ResetCalls() { - mock.lockA.Lock() - mock.calls.A = nil - mock.lockA.Unlock() - - mock.lockB.Lock() - mock.calls.B = nil - mock.lockB.Unlock() - - mock.lockC.Lock() - mock.calls.C = nil - mock.lockC.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go deleted file mode 100644 index 48da412f..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/KeyManager.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" -) - -// KeyManagerMock is a mock implementation of KeyManager. -// -// func TestSomethingThatUsesKeyManager(t *testing.T) { -// -// // make and configure a mocked KeyManager -// mockedKeyManager := &KeyManagerMock{ -// GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { -// panic("mock out the GetKey method") -// }, -// } -// -// // use mockedKeyManager in code that requires KeyManager -// // and then make assertions. -// -// } -type KeyManagerMock struct { - // GetKeyFunc mocks the GetKey method. - GetKeyFunc func(s string, v uint16) ([]byte, *test.Err) - - // calls tracks calls to the methods. - calls struct { - // GetKey holds details about calls to the GetKey method. - GetKey []struct { - // S is the s argument value. - S string - // V is the v argument value. - V uint16 - } - } - lockGetKey sync.RWMutex -} - -// GetKey calls GetKeyFunc. -func (mock *KeyManagerMock) GetKey(s string, v uint16) ([]byte, *test.Err) { - if mock.GetKeyFunc == nil { - panic("KeyManagerMock.GetKeyFunc: method is nil but KeyManager.GetKey was just called") - } - callInfo := struct { - S string - V uint16 - }{ - S: s, - V: v, - } - mock.lockGetKey.Lock() - mock.calls.GetKey = append(mock.calls.GetKey, callInfo) - mock.lockGetKey.Unlock() - return mock.GetKeyFunc(s, v) -} - -// GetKeyCalls gets all the calls that were made to GetKey. -// Check the length with: -// -// len(mockedKeyManager.GetKeyCalls()) -func (mock *KeyManagerMock) GetKeyCalls() []struct { - S string - V uint16 -} { - var calls []struct { - S string - V uint16 - } - mock.lockGetKey.RLock() - calls = mock.calls.GetKey - mock.lockGetKey.RUnlock() - return calls -} - -// ResetGetKeyCalls reset all the calls that were made to GetKey. -func (mock *KeyManagerMock) ResetGetKeyCalls() { - mock.lockGetKey.Lock() - mock.calls.GetKey = nil - mock.lockGetKey.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *KeyManagerMock) ResetCalls() { - mock.lockGetKey.Lock() - mock.calls.GetKey = nil - mock.lockGetKey.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go deleted file mode 100644 index 5924049b..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapFunc.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// MapFuncMock is a mock implementation of MapFunc. -// -// func TestSomethingThatUsesMapFunc(t *testing.T) { -// -// // make and configure a mocked MapFunc -// mockedMapFunc := &MapFuncMock{ -// GetFunc: func(m map[string]func(string) string) error { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedMapFunc in code that requires MapFunc -// // and then make assertions. -// -// } -type MapFuncMock struct { - // GetFunc mocks the Get method. - GetFunc func(m map[string]func(string) string) error - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // M is the m argument value. - M map[string]func(string) string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *MapFuncMock) Get(m map[string]func(string) string) error { - if mock.GetFunc == nil { - panic("MapFuncMock.GetFunc: method is nil but MapFunc.Get was just called") - } - callInfo := struct { - M map[string]func(string) string - }{ - M: m, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(m) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedMapFunc.GetCalls()) -func (mock *MapFuncMock) GetCalls() []struct { - M map[string]func(string) string -} { - var calls []struct { - M map[string]func(string) string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *MapFuncMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MapFuncMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go deleted file mode 100644 index 32809307..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MapToInterface.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// MapToInterfaceMock is a mock implementation of MapToInterface. -// -// func TestSomethingThatUsesMapToInterface(t *testing.T) { -// -// // make and configure a mocked MapToInterface -// mockedMapToInterface := &MapToInterfaceMock{ -// FooFunc: func(arg1 ...map[string]interface{}) { -// panic("mock out the Foo method") -// }, -// } -// -// // use mockedMapToInterface in code that requires MapToInterface -// // and then make assertions. -// -// } -type MapToInterfaceMock struct { - // FooFunc mocks the Foo method. - FooFunc func(arg1 ...map[string]interface{}) - - // calls tracks calls to the methods. - calls struct { - // Foo holds details about calls to the Foo method. - Foo []struct { - // Arg1 is the arg1 argument value. - Arg1 []map[string]interface{} - } - } - lockFoo sync.RWMutex -} - -// Foo calls FooFunc. -func (mock *MapToInterfaceMock) Foo(arg1 ...map[string]interface{}) { - if mock.FooFunc == nil { - panic("MapToInterfaceMock.FooFunc: method is nil but MapToInterface.Foo was just called") - } - callInfo := struct { - Arg1 []map[string]interface{} - }{ - Arg1: arg1, - } - mock.lockFoo.Lock() - mock.calls.Foo = append(mock.calls.Foo, callInfo) - mock.lockFoo.Unlock() - mock.FooFunc(arg1...) -} - -// FooCalls gets all the calls that were made to Foo. -// Check the length with: -// -// len(mockedMapToInterface.FooCalls()) -func (mock *MapToInterfaceMock) FooCalls() []struct { - Arg1 []map[string]interface{} -} { - var calls []struct { - Arg1 []map[string]interface{} - } - mock.lockFoo.RLock() - calls = mock.calls.Foo - mock.lockFoo.RUnlock() - return calls -} - -// ResetFooCalls reset all the calls that were made to Foo. -func (mock *MapToInterfaceMock) ResetFooCalls() { - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MapToInterfaceMock) ResetCalls() { - mock.lockFoo.Lock() - mock.calls.Foo = nil - mock.lockFoo.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go deleted file mode 100644 index d09592b2..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/MyReader.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// MyReaderMock is a mock implementation of MyReader. -// -// func TestSomethingThatUsesMyReader(t *testing.T) { -// -// // make and configure a mocked MyReader -// mockedMyReader := &MyReaderMock{ -// ReadFunc: func(p []byte) (int, error) { -// panic("mock out the Read method") -// }, -// } -// -// // use mockedMyReader in code that requires MyReader -// // and then make assertions. -// -// } -type MyReaderMock struct { - // ReadFunc mocks the Read method. - ReadFunc func(p []byte) (int, error) - - // calls tracks calls to the methods. - calls struct { - // Read holds details about calls to the Read method. - Read []struct { - // P is the p argument value. - P []byte - } - } - lockRead sync.RWMutex -} - -// Read calls ReadFunc. -func (mock *MyReaderMock) Read(p []byte) (int, error) { - if mock.ReadFunc == nil { - panic("MyReaderMock.ReadFunc: method is nil but MyReader.Read was just called") - } - callInfo := struct { - P []byte - }{ - P: p, - } - mock.lockRead.Lock() - mock.calls.Read = append(mock.calls.Read, callInfo) - mock.lockRead.Unlock() - return mock.ReadFunc(p) -} - -// ReadCalls gets all the calls that were made to Read. -// Check the length with: -// -// len(mockedMyReader.ReadCalls()) -func (mock *MyReaderMock) ReadCalls() []struct { - P []byte -} { - var calls []struct { - P []byte - } - mock.lockRead.RLock() - calls = mock.calls.Read - mock.lockRead.RUnlock() - return calls -} - -// ResetReadCalls reset all the calls that were made to Read. -func (mock *MyReaderMock) ResetReadCalls() { - mock.lockRead.Lock() - mock.calls.Read = nil - mock.lockRead.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *MyReaderMock) ResetCalls() { - mock.lockRead.Lock() - mock.calls.Read = nil - mock.lockRead.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go deleted file mode 100644 index 950b1e09..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/PanicOnNoReturnValue.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// PanicOnNoReturnValueMock is a mock implementation of PanicOnNoReturnValue. -// -// func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { -// -// // make and configure a mocked PanicOnNoReturnValue -// mockedPanicOnNoReturnValue := &PanicOnNoReturnValueMock{ -// DoSomethingFunc: func() string { -// panic("mock out the DoSomething method") -// }, -// } -// -// // use mockedPanicOnNoReturnValue in code that requires PanicOnNoReturnValue -// // and then make assertions. -// -// } -type PanicOnNoReturnValueMock struct { - // DoSomethingFunc mocks the DoSomething method. - DoSomethingFunc func() string - - // calls tracks calls to the methods. - calls struct { - // DoSomething holds details about calls to the DoSomething method. - DoSomething []struct { - } - } - lockDoSomething sync.RWMutex -} - -// DoSomething calls DoSomethingFunc. -func (mock *PanicOnNoReturnValueMock) DoSomething() string { - if mock.DoSomethingFunc == nil { - panic("PanicOnNoReturnValueMock.DoSomethingFunc: method is nil but PanicOnNoReturnValue.DoSomething was just called") - } - callInfo := struct { - }{} - mock.lockDoSomething.Lock() - mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) - mock.lockDoSomething.Unlock() - return mock.DoSomethingFunc() -} - -// DoSomethingCalls gets all the calls that were made to DoSomething. -// Check the length with: -// -// len(mockedPanicOnNoReturnValue.DoSomethingCalls()) -func (mock *PanicOnNoReturnValueMock) DoSomethingCalls() []struct { -} { - var calls []struct { - } - mock.lockDoSomething.RLock() - calls = mock.calls.DoSomething - mock.lockDoSomething.RUnlock() - return calls -} - -// ResetDoSomethingCalls reset all the calls that were made to DoSomething. -func (mock *PanicOnNoReturnValueMock) ResetDoSomethingCalls() { - mock.lockDoSomething.Lock() - mock.calls.DoSomething = nil - mock.lockDoSomething.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *PanicOnNoReturnValueMock) ResetCalls() { - mock.lockDoSomething.Lock() - mock.calls.DoSomething = nil - mock.lockDoSomething.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go deleted file mode 100644 index bf455bdc..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterMock is a mock implementation of Requester. -// -// func TestSomethingThatUsesRequester(t *testing.T) { -// -// // make and configure a mocked Requester -// mockedRequester := &RequesterMock{ -// GetFunc: func(path string) (string, error) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequester in code that requires Requester -// // and then make assertions. -// -// } -type RequesterMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (string, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterMock) Get(path string) (string, error) { - if mock.GetFunc == nil { - panic("RequesterMock.GetFunc: method is nil but Requester.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequester.GetCalls()) -func (mock *RequesterMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go deleted file mode 100644 index 3ee96f97..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester2.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// Requester2Mock is a mock implementation of Requester2. -// -// func TestSomethingThatUsesRequester2(t *testing.T) { -// -// // make and configure a mocked Requester2 -// mockedRequester2 := &Requester2Mock{ -// GetFunc: func(path string) error { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequester2 in code that requires Requester2 -// // and then make assertions. -// -// } -type Requester2Mock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) error - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *Requester2Mock) Get(path string) error { - if mock.GetFunc == nil { - panic("Requester2Mock.GetFunc: method is nil but Requester2.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequester2.GetCalls()) -func (mock *Requester2Mock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester2Mock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester2Mock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go deleted file mode 100644 index 455ba86e..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester3.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// Requester3Mock is a mock implementation of Requester3. -// -// func TestSomethingThatUsesRequester3(t *testing.T) { -// -// // make and configure a mocked Requester3 -// mockedRequester3 := &Requester3Mock{ -// GetFunc: func() error { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequester3 in code that requires Requester3 -// // and then make assertions. -// -// } -type Requester3Mock struct { - // GetFunc mocks the Get method. - GetFunc func() error - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *Requester3Mock) Get() error { - if mock.GetFunc == nil { - panic("Requester3Mock.GetFunc: method is nil but Requester3.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequester3.GetCalls()) -func (mock *Requester3Mock) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester3Mock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester3Mock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go deleted file mode 100644 index 3e640319..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Requester4.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// Requester4Mock is a mock implementation of Requester4. -// -// func TestSomethingThatUsesRequester4(t *testing.T) { -// -// // make and configure a mocked Requester4 -// mockedRequester4 := &Requester4Mock{ -// GetFunc: func() { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequester4 in code that requires Requester4 -// // and then make assertions. -// -// } -type Requester4Mock struct { - // GetFunc mocks the Get method. - GetFunc func() - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *Requester4Mock) Get() { - if mock.GetFunc == nil { - panic("Requester4Mock.GetFunc: method is nil but Requester4.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequester4.GetCalls()) -func (mock *Requester4Mock) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *Requester4Mock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *Requester4Mock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go deleted file mode 100644 index 900b6d0c..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsImport.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "encoding/json" - "sync" -) - -// RequesterArgSameAsImportMock is a mock implementation of RequesterArgSameAsImport. -// -// func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { -// -// // make and configure a mocked RequesterArgSameAsImport -// mockedRequesterArgSameAsImport := &RequesterArgSameAsImportMock{ -// GetFunc: func(jsonMoqParam string) *json.RawMessage { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterArgSameAsImport in code that requires RequesterArgSameAsImport -// // and then make assertions. -// -// } -type RequesterArgSameAsImportMock struct { - // GetFunc mocks the Get method. - GetFunc func(jsonMoqParam string) *json.RawMessage - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // JsonMoqParam is the jsonMoqParam argument value. - JsonMoqParam string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterArgSameAsImportMock) Get(jsonMoqParam string) *json.RawMessage { - if mock.GetFunc == nil { - panic("RequesterArgSameAsImportMock.GetFunc: method is nil but RequesterArgSameAsImport.Get was just called") - } - callInfo := struct { - JsonMoqParam string - }{ - JsonMoqParam: jsonMoqParam, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(jsonMoqParam) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterArgSameAsImport.GetCalls()) -func (mock *RequesterArgSameAsImportMock) GetCalls() []struct { - JsonMoqParam string -} { - var calls []struct { - JsonMoqParam string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsImportMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsImportMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go deleted file mode 100644 index fb3a41cb..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsNamedImport.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "encoding/json" - "sync" -) - -// RequesterArgSameAsNamedImportMock is a mock implementation of RequesterArgSameAsNamedImport. -// -// func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { -// -// // make and configure a mocked RequesterArgSameAsNamedImport -// mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImportMock{ -// GetFunc: func(jsonMoqParam string) *json.RawMessage { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterArgSameAsNamedImport in code that requires RequesterArgSameAsNamedImport -// // and then make assertions. -// -// } -type RequesterArgSameAsNamedImportMock struct { - // GetFunc mocks the Get method. - GetFunc func(jsonMoqParam string) *json.RawMessage - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // JsonMoqParam is the jsonMoqParam argument value. - JsonMoqParam string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterArgSameAsNamedImportMock) Get(jsonMoqParam string) *json.RawMessage { - if mock.GetFunc == nil { - panic("RequesterArgSameAsNamedImportMock.GetFunc: method is nil but RequesterArgSameAsNamedImport.Get was just called") - } - callInfo := struct { - JsonMoqParam string - }{ - JsonMoqParam: jsonMoqParam, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(jsonMoqParam) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterArgSameAsNamedImport.GetCalls()) -func (mock *RequesterArgSameAsNamedImportMock) GetCalls() []struct { - JsonMoqParam string -} { - var calls []struct { - JsonMoqParam string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsNamedImportMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsNamedImportMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go deleted file mode 100644 index 90736b41..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArgSameAsPkg.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterArgSameAsPkgMock is a mock implementation of RequesterArgSameAsPkg. -// -// func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { -// -// // make and configure a mocked RequesterArgSameAsPkg -// mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkgMock{ -// GetFunc: func(test string) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterArgSameAsPkg in code that requires RequesterArgSameAsPkg -// // and then make assertions. -// -// } -type RequesterArgSameAsPkgMock struct { - // GetFunc mocks the Get method. - GetFunc func(test string) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Test is the test argument value. - Test string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterArgSameAsPkgMock) Get(test string) { - if mock.GetFunc == nil { - panic("RequesterArgSameAsPkgMock.GetFunc: method is nil but RequesterArgSameAsPkg.Get was just called") - } - callInfo := struct { - Test string - }{ - Test: test, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - mock.GetFunc(test) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterArgSameAsPkg.GetCalls()) -func (mock *RequesterArgSameAsPkgMock) GetCalls() []struct { - Test string -} { - var calls []struct { - Test string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArgSameAsPkgMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArgSameAsPkgMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go deleted file mode 100644 index 30a646b2..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterArray.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterArrayMock is a mock implementation of RequesterArray. -// -// func TestSomethingThatUsesRequesterArray(t *testing.T) { -// -// // make and configure a mocked RequesterArray -// mockedRequesterArray := &RequesterArrayMock{ -// GetFunc: func(path string) ([2]string, error) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterArray in code that requires RequesterArray -// // and then make assertions. -// -// } -type RequesterArrayMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) ([2]string, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterArrayMock) Get(path string) ([2]string, error) { - if mock.GetFunc == nil { - panic("RequesterArrayMock.GetFunc: method is nil but RequesterArray.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterArray.GetCalls()) -func (mock *RequesterArrayMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterArrayMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterArrayMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go deleted file mode 100644 index a48e5203..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterElided.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterElidedMock is a mock implementation of RequesterElided. -// -// func TestSomethingThatUsesRequesterElided(t *testing.T) { -// -// // make and configure a mocked RequesterElided -// mockedRequesterElided := &RequesterElidedMock{ -// GetFunc: func(path string, url string) error { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterElided in code that requires RequesterElided -// // and then make assertions. -// -// } -type RequesterElidedMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string, url string) error - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - // URL is the url argument value. - URL string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterElidedMock) Get(path string, url string) error { - if mock.GetFunc == nil { - panic("RequesterElidedMock.GetFunc: method is nil but RequesterElided.Get was just called") - } - callInfo := struct { - Path string - URL string - }{ - Path: path, - URL: url, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path, url) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterElided.GetCalls()) -func (mock *RequesterElidedMock) GetCalls() []struct { - Path string - URL string -} { - var calls []struct { - Path string - URL string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterElidedMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterElidedMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go deleted file mode 100644 index 25298605..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterIface.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "io" - "sync" -) - -// RequesterIfaceMock is a mock implementation of RequesterIface. -// -// func TestSomethingThatUsesRequesterIface(t *testing.T) { -// -// // make and configure a mocked RequesterIface -// mockedRequesterIface := &RequesterIfaceMock{ -// GetFunc: func() io.Reader { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterIface in code that requires RequesterIface -// // and then make assertions. -// -// } -type RequesterIfaceMock struct { - // GetFunc mocks the Get method. - GetFunc func() io.Reader - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterIfaceMock) Get() io.Reader { - if mock.GetFunc == nil { - panic("RequesterIfaceMock.GetFunc: method is nil but RequesterIface.Get was just called") - } - callInfo := struct { - }{} - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc() -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterIface.GetCalls()) -func (mock *RequesterIfaceMock) GetCalls() []struct { -} { - var calls []struct { - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterIfaceMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterIfaceMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go deleted file mode 100644 index 91fd8112..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterNS.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "net/http" - "sync" -) - -// RequesterNSMock is a mock implementation of RequesterNS. -// -// func TestSomethingThatUsesRequesterNS(t *testing.T) { -// -// // make and configure a mocked RequesterNS -// mockedRequesterNS := &RequesterNSMock{ -// GetFunc: func(path string) (http.Response, error) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterNS in code that requires RequesterNS -// // and then make assertions. -// -// } -type RequesterNSMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (http.Response, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterNSMock) Get(path string) (http.Response, error) { - if mock.GetFunc == nil { - panic("RequesterNSMock.GetFunc: method is nil but RequesterNS.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterNS.GetCalls()) -func (mock *RequesterNSMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterNSMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterNSMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go deleted file mode 100644 index 9a3f6031..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterPtr.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterPtrMock is a mock implementation of RequesterPtr. -// -// func TestSomethingThatUsesRequesterPtr(t *testing.T) { -// -// // make and configure a mocked RequesterPtr -// mockedRequesterPtr := &RequesterPtrMock{ -// GetFunc: func(path string) (*string, error) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterPtr in code that requires RequesterPtr -// // and then make assertions. -// -// } -type RequesterPtrMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (*string, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterPtrMock) Get(path string) (*string, error) { - if mock.GetFunc == nil { - panic("RequesterPtrMock.GetFunc: method is nil but RequesterPtr.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterPtr.GetCalls()) -func (mock *RequesterPtrMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterPtrMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterPtrMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go deleted file mode 100644 index ade8660d..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterReturnElided.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterReturnElidedMock is a mock implementation of RequesterReturnElided. -// -// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { -// -// // make and configure a mocked RequesterReturnElided -// mockedRequesterReturnElided := &RequesterReturnElidedMock{ -// GetFunc: func(path string) (int, int, int, error) { -// panic("mock out the Get method") -// }, -// PutFunc: func(path string) (int, error) { -// panic("mock out the Put method") -// }, -// } -// -// // use mockedRequesterReturnElided in code that requires RequesterReturnElided -// // and then make assertions. -// -// } -type RequesterReturnElidedMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) (int, int, int, error) - - // PutFunc mocks the Put method. - PutFunc func(path string) (int, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - // Put holds details about calls to the Put method. - Put []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex - lockPut sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterReturnElidedMock) Get(path string) (int, int, int, error) { - if mock.GetFunc == nil { - panic("RequesterReturnElidedMock.GetFunc: method is nil but RequesterReturnElided.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterReturnElided.GetCalls()) -func (mock *RequesterReturnElidedMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterReturnElidedMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// Put calls PutFunc. -func (mock *RequesterReturnElidedMock) Put(path string) (int, error) { - if mock.PutFunc == nil { - panic("RequesterReturnElidedMock.PutFunc: method is nil but RequesterReturnElided.Put was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockPut.Lock() - mock.calls.Put = append(mock.calls.Put, callInfo) - mock.lockPut.Unlock() - return mock.PutFunc(path) -} - -// PutCalls gets all the calls that were made to Put. -// Check the length with: -// -// len(mockedRequesterReturnElided.PutCalls()) -func (mock *RequesterReturnElidedMock) PutCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockPut.RLock() - calls = mock.calls.Put - mock.lockPut.RUnlock() - return calls -} - -// ResetPutCalls reset all the calls that were made to Put. -func (mock *RequesterReturnElidedMock) ResetPutCalls() { - mock.lockPut.Lock() - mock.calls.Put = nil - mock.lockPut.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterReturnElidedMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() - - mock.lockPut.Lock() - mock.calls.Put = nil - mock.lockPut.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go deleted file mode 100644 index 599e6ff1..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterSlice.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// RequesterSliceMock is a mock implementation of RequesterSlice. -// -// func TestSomethingThatUsesRequesterSlice(t *testing.T) { -// -// // make and configure a mocked RequesterSlice -// mockedRequesterSlice := &RequesterSliceMock{ -// GetFunc: func(path string) ([]string, error) { -// panic("mock out the Get method") -// }, -// } -// -// // use mockedRequesterSlice in code that requires RequesterSlice -// // and then make assertions. -// -// } -type RequesterSliceMock struct { - // GetFunc mocks the Get method. - GetFunc func(path string) ([]string, error) - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Path is the path argument value. - Path string - } - } - lockGet sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterSliceMock) Get(path string) ([]string, error) { - if mock.GetFunc == nil { - panic("RequesterSliceMock.GetFunc: method is nil but RequesterSlice.Get was just called") - } - callInfo := struct { - Path string - }{ - Path: path, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(path) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterSlice.GetCalls()) -func (mock *RequesterSliceMock) GetCalls() []struct { - Path string -} { - var calls []struct { - Path string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterSliceMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterSliceMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go deleted file mode 100644 index a7905429..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/RequesterVariadic.go +++ /dev/null @@ -1,262 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "io" - "sync" -) - -// RequesterVariadicMock is a mock implementation of RequesterVariadic. -// -// func TestSomethingThatUsesRequesterVariadic(t *testing.T) { -// -// // make and configure a mocked RequesterVariadic -// mockedRequesterVariadic := &RequesterVariadicMock{ -// GetFunc: func(values ...string) bool { -// panic("mock out the Get method") -// }, -// MultiWriteToFileFunc: func(filename string, w ...io.Writer) string { -// panic("mock out the MultiWriteToFile method") -// }, -// OneInterfaceFunc: func(a ...interface{}) bool { -// panic("mock out the OneInterface method") -// }, -// SprintfFunc: func(format string, a ...interface{}) string { -// panic("mock out the Sprintf method") -// }, -// } -// -// // use mockedRequesterVariadic in code that requires RequesterVariadic -// // and then make assertions. -// -// } -type RequesterVariadicMock struct { - // GetFunc mocks the Get method. - GetFunc func(values ...string) bool - - // MultiWriteToFileFunc mocks the MultiWriteToFile method. - MultiWriteToFileFunc func(filename string, w ...io.Writer) string - - // OneInterfaceFunc mocks the OneInterface method. - OneInterfaceFunc func(a ...interface{}) bool - - // SprintfFunc mocks the Sprintf method. - SprintfFunc func(format string, a ...interface{}) string - - // calls tracks calls to the methods. - calls struct { - // Get holds details about calls to the Get method. - Get []struct { - // Values is the values argument value. - Values []string - } - // MultiWriteToFile holds details about calls to the MultiWriteToFile method. - MultiWriteToFile []struct { - // Filename is the filename argument value. - Filename string - // W is the w argument value. - W []io.Writer - } - // OneInterface holds details about calls to the OneInterface method. - OneInterface []struct { - // A is the a argument value. - A []interface{} - } - // Sprintf holds details about calls to the Sprintf method. - Sprintf []struct { - // Format is the format argument value. - Format string - // A is the a argument value. - A []interface{} - } - } - lockGet sync.RWMutex - lockMultiWriteToFile sync.RWMutex - lockOneInterface sync.RWMutex - lockSprintf sync.RWMutex -} - -// Get calls GetFunc. -func (mock *RequesterVariadicMock) Get(values ...string) bool { - if mock.GetFunc == nil { - panic("RequesterVariadicMock.GetFunc: method is nil but RequesterVariadic.Get was just called") - } - callInfo := struct { - Values []string - }{ - Values: values, - } - mock.lockGet.Lock() - mock.calls.Get = append(mock.calls.Get, callInfo) - mock.lockGet.Unlock() - return mock.GetFunc(values...) -} - -// GetCalls gets all the calls that were made to Get. -// Check the length with: -// -// len(mockedRequesterVariadic.GetCalls()) -func (mock *RequesterVariadicMock) GetCalls() []struct { - Values []string -} { - var calls []struct { - Values []string - } - mock.lockGet.RLock() - calls = mock.calls.Get - mock.lockGet.RUnlock() - return calls -} - -// ResetGetCalls reset all the calls that were made to Get. -func (mock *RequesterVariadicMock) ResetGetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() -} - -// MultiWriteToFile calls MultiWriteToFileFunc. -func (mock *RequesterVariadicMock) MultiWriteToFile(filename string, w ...io.Writer) string { - if mock.MultiWriteToFileFunc == nil { - panic("RequesterVariadicMock.MultiWriteToFileFunc: method is nil but RequesterVariadic.MultiWriteToFile was just called") - } - callInfo := struct { - Filename string - W []io.Writer - }{ - Filename: filename, - W: w, - } - mock.lockMultiWriteToFile.Lock() - mock.calls.MultiWriteToFile = append(mock.calls.MultiWriteToFile, callInfo) - mock.lockMultiWriteToFile.Unlock() - return mock.MultiWriteToFileFunc(filename, w...) -} - -// MultiWriteToFileCalls gets all the calls that were made to MultiWriteToFile. -// Check the length with: -// -// len(mockedRequesterVariadic.MultiWriteToFileCalls()) -func (mock *RequesterVariadicMock) MultiWriteToFileCalls() []struct { - Filename string - W []io.Writer -} { - var calls []struct { - Filename string - W []io.Writer - } - mock.lockMultiWriteToFile.RLock() - calls = mock.calls.MultiWriteToFile - mock.lockMultiWriteToFile.RUnlock() - return calls -} - -// ResetMultiWriteToFileCalls reset all the calls that were made to MultiWriteToFile. -func (mock *RequesterVariadicMock) ResetMultiWriteToFileCalls() { - mock.lockMultiWriteToFile.Lock() - mock.calls.MultiWriteToFile = nil - mock.lockMultiWriteToFile.Unlock() -} - -// OneInterface calls OneInterfaceFunc. -func (mock *RequesterVariadicMock) OneInterface(a ...interface{}) bool { - if mock.OneInterfaceFunc == nil { - panic("RequesterVariadicMock.OneInterfaceFunc: method is nil but RequesterVariadic.OneInterface was just called") - } - callInfo := struct { - A []interface{} - }{ - A: a, - } - mock.lockOneInterface.Lock() - mock.calls.OneInterface = append(mock.calls.OneInterface, callInfo) - mock.lockOneInterface.Unlock() - return mock.OneInterfaceFunc(a...) -} - -// OneInterfaceCalls gets all the calls that were made to OneInterface. -// Check the length with: -// -// len(mockedRequesterVariadic.OneInterfaceCalls()) -func (mock *RequesterVariadicMock) OneInterfaceCalls() []struct { - A []interface{} -} { - var calls []struct { - A []interface{} - } - mock.lockOneInterface.RLock() - calls = mock.calls.OneInterface - mock.lockOneInterface.RUnlock() - return calls -} - -// ResetOneInterfaceCalls reset all the calls that were made to OneInterface. -func (mock *RequesterVariadicMock) ResetOneInterfaceCalls() { - mock.lockOneInterface.Lock() - mock.calls.OneInterface = nil - mock.lockOneInterface.Unlock() -} - -// Sprintf calls SprintfFunc. -func (mock *RequesterVariadicMock) Sprintf(format string, a ...interface{}) string { - if mock.SprintfFunc == nil { - panic("RequesterVariadicMock.SprintfFunc: method is nil but RequesterVariadic.Sprintf was just called") - } - callInfo := struct { - Format string - A []interface{} - }{ - Format: format, - A: a, - } - mock.lockSprintf.Lock() - mock.calls.Sprintf = append(mock.calls.Sprintf, callInfo) - mock.lockSprintf.Unlock() - return mock.SprintfFunc(format, a...) -} - -// SprintfCalls gets all the calls that were made to Sprintf. -// Check the length with: -// -// len(mockedRequesterVariadic.SprintfCalls()) -func (mock *RequesterVariadicMock) SprintfCalls() []struct { - Format string - A []interface{} -} { - var calls []struct { - Format string - A []interface{} - } - mock.lockSprintf.RLock() - calls = mock.calls.Sprintf - mock.lockSprintf.RUnlock() - return calls -} - -// ResetSprintfCalls reset all the calls that were made to Sprintf. -func (mock *RequesterVariadicMock) ResetSprintfCalls() { - mock.lockSprintf.Lock() - mock.calls.Sprintf = nil - mock.lockSprintf.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *RequesterVariadicMock) ResetCalls() { - mock.lockGet.Lock() - mock.calls.Get = nil - mock.lockGet.Unlock() - - mock.lockMultiWriteToFile.Lock() - mock.calls.MultiWriteToFile = nil - mock.lockMultiWriteToFile.Unlock() - - mock.lockOneInterface.Lock() - mock.calls.OneInterface = nil - mock.lockOneInterface.Unlock() - - mock.lockSprintf.Lock() - mock.calls.Sprintf = nil - mock.lockSprintf.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go deleted file mode 100644 index 26fcae36..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Sibling.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// SiblingMock is a mock implementation of Sibling. -// -// func TestSomethingThatUsesSibling(t *testing.T) { -// -// // make and configure a mocked Sibling -// mockedSibling := &SiblingMock{ -// DoSomethingFunc: func() { -// panic("mock out the DoSomething method") -// }, -// } -// -// // use mockedSibling in code that requires Sibling -// // and then make assertions. -// -// } -type SiblingMock struct { - // DoSomethingFunc mocks the DoSomething method. - DoSomethingFunc func() - - // calls tracks calls to the methods. - calls struct { - // DoSomething holds details about calls to the DoSomething method. - DoSomething []struct { - } - } - lockDoSomething sync.RWMutex -} - -// DoSomething calls DoSomethingFunc. -func (mock *SiblingMock) DoSomething() { - if mock.DoSomethingFunc == nil { - panic("SiblingMock.DoSomethingFunc: method is nil but Sibling.DoSomething was just called") - } - callInfo := struct { - }{} - mock.lockDoSomething.Lock() - mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) - mock.lockDoSomething.Unlock() - mock.DoSomethingFunc() -} - -// DoSomethingCalls gets all the calls that were made to DoSomething. -// Check the length with: -// -// len(mockedSibling.DoSomethingCalls()) -func (mock *SiblingMock) DoSomethingCalls() []struct { -} { - var calls []struct { - } - mock.lockDoSomething.RLock() - calls = mock.calls.DoSomething - mock.lockDoSomething.RUnlock() - return calls -} - -// ResetDoSomethingCalls reset all the calls that were made to DoSomething. -func (mock *SiblingMock) ResetDoSomethingCalls() { - mock.lockDoSomething.Lock() - mock.calls.DoSomething = nil - mock.lockDoSomething.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *SiblingMock) ResetCalls() { - mock.lockDoSomething.Lock() - mock.calls.DoSomething = nil - mock.lockDoSomething.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go deleted file mode 100644 index 456f63d3..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/StructWithTag.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// StructWithTagMock is a mock implementation of StructWithTag. -// -// func TestSomethingThatUsesStructWithTag(t *testing.T) { -// -// // make and configure a mocked StructWithTag -// mockedStructWithTag := &StructWithTagMock{ -// MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { -// panic("mock out the MethodA method") -// }, -// } -// -// // use mockedStructWithTag in code that requires StructWithTag -// // and then make assertions. -// -// } -type StructWithTagMock struct { - // MethodAFunc mocks the MethodA method. - MethodAFunc func(v *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" - }) *struct { - FieldC int "json:\"field_c\"" - FieldD int "json:\"field_d\" xml:\"field_d\"" - } - - // calls tracks calls to the methods. - calls struct { - // MethodA holds details about calls to the MethodA method. - MethodA []struct { - // V is the v argument value. - V *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" - } - } - } - lockMethodA sync.RWMutex -} - -// MethodA calls MethodAFunc. -func (mock *StructWithTagMock) MethodA(v *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" -}) *struct { - FieldC int "json:\"field_c\"" - FieldD int "json:\"field_d\" xml:\"field_d\"" -} { - if mock.MethodAFunc == nil { - panic("StructWithTagMock.MethodAFunc: method is nil but StructWithTag.MethodA was just called") - } - callInfo := struct { - V *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" - } - }{ - V: v, - } - mock.lockMethodA.Lock() - mock.calls.MethodA = append(mock.calls.MethodA, callInfo) - mock.lockMethodA.Unlock() - return mock.MethodAFunc(v) -} - -// MethodACalls gets all the calls that were made to MethodA. -// Check the length with: -// -// len(mockedStructWithTag.MethodACalls()) -func (mock *StructWithTagMock) MethodACalls() []struct { - V *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" - } -} { - var calls []struct { - V *struct { - FieldA int "json:\"field_a\"" - FieldB int "json:\"field_b\" xml:\"field_b\"" - } - } - mock.lockMethodA.RLock() - calls = mock.calls.MethodA - mock.lockMethodA.RUnlock() - return calls -} - -// ResetMethodACalls reset all the calls that were made to MethodA. -func (mock *StructWithTagMock) ResetMethodACalls() { - mock.lockMethodA.Lock() - mock.calls.MethodA = nil - mock.lockMethodA.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *StructWithTagMock) ResetCalls() { - mock.lockMethodA.Lock() - mock.calls.MethodA = nil - mock.lockMethodA.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go deleted file mode 100644 index 1b55833e..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/UsesOtherPkgIface.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" - - test "github.com/vektra/mockery/v2/pkg/fixtures" -) - -// UsesOtherPkgIfaceMock is a mock implementation of UsesOtherPkgIface. -// -// func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { -// -// // make and configure a mocked UsesOtherPkgIface -// mockedUsesOtherPkgIface := &UsesOtherPkgIfaceMock{ -// DoSomethingElseFunc: func(obj test.Sibling) { -// panic("mock out the DoSomethingElse method") -// }, -// } -// -// // use mockedUsesOtherPkgIface in code that requires UsesOtherPkgIface -// // and then make assertions. -// -// } -type UsesOtherPkgIfaceMock struct { - // DoSomethingElseFunc mocks the DoSomethingElse method. - DoSomethingElseFunc func(obj test.Sibling) - - // calls tracks calls to the methods. - calls struct { - // DoSomethingElse holds details about calls to the DoSomethingElse method. - DoSomethingElse []struct { - // Obj is the obj argument value. - Obj test.Sibling - } - } - lockDoSomethingElse sync.RWMutex -} - -// DoSomethingElse calls DoSomethingElseFunc. -func (mock *UsesOtherPkgIfaceMock) DoSomethingElse(obj test.Sibling) { - if mock.DoSomethingElseFunc == nil { - panic("UsesOtherPkgIfaceMock.DoSomethingElseFunc: method is nil but UsesOtherPkgIface.DoSomethingElse was just called") - } - callInfo := struct { - Obj test.Sibling - }{ - Obj: obj, - } - mock.lockDoSomethingElse.Lock() - mock.calls.DoSomethingElse = append(mock.calls.DoSomethingElse, callInfo) - mock.lockDoSomethingElse.Unlock() - mock.DoSomethingElseFunc(obj) -} - -// DoSomethingElseCalls gets all the calls that were made to DoSomethingElse. -// Check the length with: -// -// len(mockedUsesOtherPkgIface.DoSomethingElseCalls()) -func (mock *UsesOtherPkgIfaceMock) DoSomethingElseCalls() []struct { - Obj test.Sibling -} { - var calls []struct { - Obj test.Sibling - } - mock.lockDoSomethingElse.RLock() - calls = mock.calls.DoSomethingElse - mock.lockDoSomethingElse.RUnlock() - return calls -} - -// ResetDoSomethingElseCalls reset all the calls that were made to DoSomethingElse. -func (mock *UsesOtherPkgIfaceMock) ResetDoSomethingElseCalls() { - mock.lockDoSomethingElse.Lock() - mock.calls.DoSomethingElse = nil - mock.lockDoSomethingElse.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *UsesOtherPkgIfaceMock) ResetCalls() { - mock.lockDoSomethingElse.Lock() - mock.calls.DoSomethingElse = nil - mock.lockDoSomethingElse.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go deleted file mode 100644 index 8eb17b94..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/Variadic.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// VariadicMock is a mock implementation of Variadic. -// -// func TestSomethingThatUsesVariadic(t *testing.T) { -// -// // make and configure a mocked Variadic -// mockedVariadic := &VariadicMock{ -// VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { -// panic("mock out the VariadicFunction method") -// }, -// } -// -// // use mockedVariadic in code that requires Variadic -// // and then make assertions. -// -// } -type VariadicMock struct { - // VariadicFunctionFunc mocks the VariadicFunction method. - VariadicFunctionFunc func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error - - // calls tracks calls to the methods. - calls struct { - // VariadicFunction holds details about calls to the VariadicFunction method. - VariadicFunction []struct { - // Str is the str argument value. - Str string - // VFunc is the vFunc argument value. - VFunc func(args1 string, args2 ...interface{}) interface{} - } - } - lockVariadicFunction sync.RWMutex -} - -// VariadicFunction calls VariadicFunctionFunc. -func (mock *VariadicMock) VariadicFunction(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { - if mock.VariadicFunctionFunc == nil { - panic("VariadicMock.VariadicFunctionFunc: method is nil but Variadic.VariadicFunction was just called") - } - callInfo := struct { - Str string - VFunc func(args1 string, args2 ...interface{}) interface{} - }{ - Str: str, - VFunc: vFunc, - } - mock.lockVariadicFunction.Lock() - mock.calls.VariadicFunction = append(mock.calls.VariadicFunction, callInfo) - mock.lockVariadicFunction.Unlock() - return mock.VariadicFunctionFunc(str, vFunc) -} - -// VariadicFunctionCalls gets all the calls that were made to VariadicFunction. -// Check the length with: -// -// len(mockedVariadic.VariadicFunctionCalls()) -func (mock *VariadicMock) VariadicFunctionCalls() []struct { - Str string - VFunc func(args1 string, args2 ...interface{}) interface{} -} { - var calls []struct { - Str string - VFunc func(args1 string, args2 ...interface{}) interface{} - } - mock.lockVariadicFunction.RLock() - calls = mock.calls.VariadicFunction - mock.lockVariadicFunction.RUnlock() - return calls -} - -// ResetVariadicFunctionCalls reset all the calls that were made to VariadicFunction. -func (mock *VariadicMock) ResetVariadicFunctionCalls() { - mock.lockVariadicFunction.Lock() - mock.calls.VariadicFunction = nil - mock.lockVariadicFunction.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *VariadicMock) ResetCalls() { - mock.lockVariadicFunction.Lock() - mock.calls.VariadicFunction = nil - mock.lockVariadicFunction.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go deleted file mode 100644 index 6a8f78a6..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicNoReturnInterface.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// VariadicNoReturnInterfaceMock is a mock implementation of VariadicNoReturnInterface. -// -// func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { -// -// // make and configure a mocked VariadicNoReturnInterface -// mockedVariadicNoReturnInterface := &VariadicNoReturnInterfaceMock{ -// VariadicNoReturnFunc: func(j int, is ...interface{}) { -// panic("mock out the VariadicNoReturn method") -// }, -// } -// -// // use mockedVariadicNoReturnInterface in code that requires VariadicNoReturnInterface -// // and then make assertions. -// -// } -type VariadicNoReturnInterfaceMock struct { - // VariadicNoReturnFunc mocks the VariadicNoReturn method. - VariadicNoReturnFunc func(j int, is ...interface{}) - - // calls tracks calls to the methods. - calls struct { - // VariadicNoReturn holds details about calls to the VariadicNoReturn method. - VariadicNoReturn []struct { - // J is the j argument value. - J int - // Is is the is argument value. - Is []interface{} - } - } - lockVariadicNoReturn sync.RWMutex -} - -// VariadicNoReturn calls VariadicNoReturnFunc. -func (mock *VariadicNoReturnInterfaceMock) VariadicNoReturn(j int, is ...interface{}) { - if mock.VariadicNoReturnFunc == nil { - panic("VariadicNoReturnInterfaceMock.VariadicNoReturnFunc: method is nil but VariadicNoReturnInterface.VariadicNoReturn was just called") - } - callInfo := struct { - J int - Is []interface{} - }{ - J: j, - Is: is, - } - mock.lockVariadicNoReturn.Lock() - mock.calls.VariadicNoReturn = append(mock.calls.VariadicNoReturn, callInfo) - mock.lockVariadicNoReturn.Unlock() - mock.VariadicNoReturnFunc(j, is...) -} - -// VariadicNoReturnCalls gets all the calls that were made to VariadicNoReturn. -// Check the length with: -// -// len(mockedVariadicNoReturnInterface.VariadicNoReturnCalls()) -func (mock *VariadicNoReturnInterfaceMock) VariadicNoReturnCalls() []struct { - J int - Is []interface{} -} { - var calls []struct { - J int - Is []interface{} - } - mock.lockVariadicNoReturn.RLock() - calls = mock.calls.VariadicNoReturn - mock.lockVariadicNoReturn.RUnlock() - return calls -} - -// ResetVariadicNoReturnCalls reset all the calls that were made to VariadicNoReturn. -func (mock *VariadicNoReturnInterfaceMock) ResetVariadicNoReturnCalls() { - mock.lockVariadicNoReturn.Lock() - mock.calls.VariadicNoReturn = nil - mock.lockVariadicNoReturn.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *VariadicNoReturnInterfaceMock) ResetCalls() { - mock.lockVariadicNoReturn.Lock() - mock.calls.VariadicNoReturn = nil - mock.lockVariadicNoReturn.Unlock() -} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go deleted file mode 100644 index cd05c24a..00000000 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/VariadicReturnFunc.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery; DO NOT EDIT. -// github.com/vektra/mockery - -package test - -import ( - "sync" -) - -// VariadicReturnFuncMock is a mock implementation of VariadicReturnFunc. -// -// func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { -// -// // make and configure a mocked VariadicReturnFunc -// mockedVariadicReturnFunc := &VariadicReturnFuncMock{ -// SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { -// panic("mock out the SampleMethod method") -// }, -// } -// -// // use mockedVariadicReturnFunc in code that requires VariadicReturnFunc -// // and then make assertions. -// -// } -type VariadicReturnFuncMock struct { - // SampleMethodFunc mocks the SampleMethod method. - SampleMethodFunc func(str string) func(str string, arr []int, a ...interface{}) - - // calls tracks calls to the methods. - calls struct { - // SampleMethod holds details about calls to the SampleMethod method. - SampleMethod []struct { - // Str is the str argument value. - Str string - } - } - lockSampleMethod sync.RWMutex -} - -// SampleMethod calls SampleMethodFunc. -func (mock *VariadicReturnFuncMock) SampleMethod(str string) func(str string, arr []int, a ...interface{}) { - if mock.SampleMethodFunc == nil { - panic("VariadicReturnFuncMock.SampleMethodFunc: method is nil but VariadicReturnFunc.SampleMethod was just called") - } - callInfo := struct { - Str string - }{ - Str: str, - } - mock.lockSampleMethod.Lock() - mock.calls.SampleMethod = append(mock.calls.SampleMethod, callInfo) - mock.lockSampleMethod.Unlock() - return mock.SampleMethodFunc(str) -} - -// SampleMethodCalls gets all the calls that were made to SampleMethod. -// Check the length with: -// -// len(mockedVariadicReturnFunc.SampleMethodCalls()) -func (mock *VariadicReturnFuncMock) SampleMethodCalls() []struct { - Str string -} { - var calls []struct { - Str string - } - mock.lockSampleMethod.RLock() - calls = mock.calls.SampleMethod - mock.lockSampleMethod.RUnlock() - return calls -} - -// ResetSampleMethodCalls reset all the calls that were made to SampleMethod. -func (mock *VariadicReturnFuncMock) ResetSampleMethodCalls() { - mock.lockSampleMethod.Lock() - mock.calls.SampleMethod = nil - mock.lockSampleMethod.Unlock() -} - -// ResetCalls reset all the calls that were made to all mocked methods. -func (mock *VariadicReturnFuncMock) ResetCalls() { - mock.lockSampleMethod.Lock() - mock.calls.SampleMethod = nil - mock.lockSampleMethod.Unlock() -} From a82b2655022e400b1d9b53125c13c49ce5ff7103 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 14:03:15 -0600 Subject: [PATCH 44/50] Fix moq generation when inpackage=True --- .mockery-moq.yaml | 1 + .../vektra/mockery/v2/pkg/fixtures/a_moq.go | 83 +++++ .../v2/pkg/fixtures/async_producer_moq.go | 177 ++++++++++ .../mockery/v2/pkg/fixtures/blank_moq.go | 88 +++++ .../v2/pkg/fixtures/consul_lock_moq.go | 136 ++++++++ .../v2/pkg/fixtures/embedded_get_moq.go | 83 +++++ .../mockery/v2/pkg/fixtures/example_moq.go | 139 ++++++++ .../mockery/v2/pkg/fixtures/expecter_moq.go | 319 ++++++++++++++++++ .../mockery/v2/pkg/fixtures/fooer_moq.go | 198 +++++++++++ .../pkg/fixtures/func_args_collision_moq.go | 88 +++++ .../v2/pkg/fixtures/get_generic_moq.go | 83 +++++ .../mockery/v2/pkg/fixtures/get_int_moq.go | 81 +++++ .../has_conflicting_nested_imports_moq.go | 139 ++++++++ .../fixtures/imports_same_as_package_moq.go | 187 ++++++++++ .../v2/pkg/fixtures/key_manager_moq.go | 96 ++++++ .../mockery/v2/pkg/fixtures/map_func_moq.go | 88 +++++ .../v2/pkg/fixtures/map_to_interface_moq.go | 88 +++++ .../mockery/v2/pkg/fixtures/my_reader_moq.go | 88 +++++ .../fixtures/panic_on_no_return_value_moq.go | 81 +++++ .../mockery/v2/pkg/fixtures/requester2_moq.go | 88 +++++ .../mockery/v2/pkg/fixtures/requester3_moq.go | 81 +++++ .../mockery/v2/pkg/fixtures/requester4_moq.go | 81 +++++ .../requester_arg_same_as_import_moq.go | 89 +++++ .../requester_arg_same_as_named_import_moq.go | 89 +++++ .../fixtures/requester_arg_same_as_pkg_moq.go | 88 +++++ .../v2/pkg/fixtures/requester_array_moq.go | 88 +++++ .../v2/pkg/fixtures/requester_elided_moq.go | 94 ++++++ .../v2/pkg/fixtures/requester_iface_moq.go | 82 +++++ .../mockery/v2/pkg/fixtures/requester_moq.go | 88 +++++ .../v2/pkg/fixtures/requester_ns_moq.go | 89 +++++ .../v2/pkg/fixtures/requester_ptr_moq.go | 88 +++++ .../fixtures/requester_return_elided_moq.go | 143 ++++++++ .../v2/pkg/fixtures/requester_slice_moq.go | 88 +++++ .../v2/pkg/fixtures/requester_variadic_moq.go | 266 +++++++++++++++ .../mockery/v2/pkg/fixtures/sibling_moq.go | 81 +++++ .../v2/pkg/fixtures/struct_with_tag_moq.go | 112 ++++++ .../pkg/fixtures/uses_other_pkg_iface_moq.go | 90 +++++ .../mockery/v2/pkg/fixtures/variadic_moq.go | 94 ++++++ .../variadic_no_return_interface_moq.go | 94 ++++++ .../pkg/fixtures/variadic_return_func_moq.go | 88 +++++ pkg/fixtures/inpackage/foo_moq.go | 74 ++++ pkg/fixtures/inpackage/foo_test.go | 16 + pkg/fixtures/recursive_generation/Foo_mock.go | 77 +++++ .../recursive_generation/subpkg1/Foo_mock.go | 77 +++++ .../recursive_generation/subpkg2/Foo_mock.go | 77 +++++ .../Foo_mock.go | 77 +++++ pkg/generator/template_generator.go | 4 +- pkg/outputter.go | 18 +- pkg/registry/registry.go | 10 +- 49 files changed, 4765 insertions(+), 9 deletions(-) create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go create mode 100644 mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go create mode 100644 pkg/fixtures/inpackage/foo_moq.go create mode 100644 pkg/fixtures/inpackage/foo_test.go create mode 100644 pkg/fixtures/recursive_generation/Foo_mock.go create mode 100644 pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go create mode 100644 pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go create mode 100644 pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 5f4eb1c8..51bf00c9 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -19,4 +19,5 @@ packages: dir: "{{.InterfaceDir}}" all: True outpkg: "{{.PackageName}}" + inpackage: true \ No newline at end of file diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go new file mode 100644 index 00000000..850de8f6 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go @@ -0,0 +1,83 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that AMoq does implement A. +// If this is not the case, regenerate this file with moq. +var _ A = &AMoq{} + +// AMoq is a mock implementation of A. +// +// func TestSomethingThatUsesA(t *testing.T) { +// +// // make and configure a mocked A +// mockedA := &AMoq{ +// CallFunc: func() (test.B, error) { +// panic("mock out the Call method") +// }, +// } +// +// // use mockedA in code that requires A +// // and then make assertions. +// +// } +type AMoq struct { + // CallFunc mocks the Call method. + CallFunc func() (test.B, error) + + // calls tracks calls to the methods. + calls struct { + // Call holds details about calls to the Call method. + Call []struct { + } + } + lockCall sync.RWMutex +} + +// Call calls CallFunc. +func (mock *AMoq) Call() (test.B, error) { + if mock.CallFunc == nil { + panic("AMoq.CallFunc: method is nil but A.Call was just called") + } + callInfo := struct { + }{} + mock.lockCall.Lock() + mock.calls.Call = append(mock.calls.Call, callInfo) + mock.lockCall.Unlock() + return mock.CallFunc() +} + +// CallCalls gets all the calls that were made to Call. +// Check the length with: +// +// len(mockedA.CallCalls()) +func (mock *AMoq) CallCalls() []struct { +} { + var calls []struct { + } + mock.lockCall.RLock() + calls = mock.calls.Call + mock.lockCall.RUnlock() + return calls +} + +// ResetCallCalls reset all the calls that were made to Call. +func (mock *AMoq) ResetCallCalls() { + mock.lockCall.Lock() + mock.calls.Call = nil + mock.lockCall.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *AMoq) ResetCalls() { + mock.lockCall.Lock() + mock.calls.Call = nil + mock.lockCall.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go new file mode 100644 index 00000000..4e8cf652 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go @@ -0,0 +1,177 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that AsyncProducerMoq does implement AsyncProducer. +// If this is not the case, regenerate this file with moq. +var _ AsyncProducer = &AsyncProducerMoq{} + +// AsyncProducerMoq is a mock implementation of AsyncProducer. +// +// func TestSomethingThatUsesAsyncProducer(t *testing.T) { +// +// // make and configure a mocked AsyncProducer +// mockedAsyncProducer := &AsyncProducerMoq{ +// InputFunc: func() chan<- bool { +// panic("mock out the Input method") +// }, +// OutputFunc: func() <-chan bool { +// panic("mock out the Output method") +// }, +// WhateverFunc: func() chan bool { +// panic("mock out the Whatever method") +// }, +// } +// +// // use mockedAsyncProducer in code that requires AsyncProducer +// // and then make assertions. +// +// } +type AsyncProducerMoq struct { + // InputFunc mocks the Input method. + InputFunc func() chan<- bool + + // OutputFunc mocks the Output method. + OutputFunc func() <-chan bool + + // WhateverFunc mocks the Whatever method. + WhateverFunc func() chan bool + + // calls tracks calls to the methods. + calls struct { + // Input holds details about calls to the Input method. + Input []struct { + } + // Output holds details about calls to the Output method. + Output []struct { + } + // Whatever holds details about calls to the Whatever method. + Whatever []struct { + } + } + lockInput sync.RWMutex + lockOutput sync.RWMutex + lockWhatever sync.RWMutex +} + +// Input calls InputFunc. +func (mock *AsyncProducerMoq) Input() chan<- bool { + if mock.InputFunc == nil { + panic("AsyncProducerMoq.InputFunc: method is nil but AsyncProducer.Input was just called") + } + callInfo := struct { + }{} + mock.lockInput.Lock() + mock.calls.Input = append(mock.calls.Input, callInfo) + mock.lockInput.Unlock() + return mock.InputFunc() +} + +// InputCalls gets all the calls that were made to Input. +// Check the length with: +// +// len(mockedAsyncProducer.InputCalls()) +func (mock *AsyncProducerMoq) InputCalls() []struct { +} { + var calls []struct { + } + mock.lockInput.RLock() + calls = mock.calls.Input + mock.lockInput.RUnlock() + return calls +} + +// ResetInputCalls reset all the calls that were made to Input. +func (mock *AsyncProducerMoq) ResetInputCalls() { + mock.lockInput.Lock() + mock.calls.Input = nil + mock.lockInput.Unlock() +} + +// Output calls OutputFunc. +func (mock *AsyncProducerMoq) Output() <-chan bool { + if mock.OutputFunc == nil { + panic("AsyncProducerMoq.OutputFunc: method is nil but AsyncProducer.Output was just called") + } + callInfo := struct { + }{} + mock.lockOutput.Lock() + mock.calls.Output = append(mock.calls.Output, callInfo) + mock.lockOutput.Unlock() + return mock.OutputFunc() +} + +// OutputCalls gets all the calls that were made to Output. +// Check the length with: +// +// len(mockedAsyncProducer.OutputCalls()) +func (mock *AsyncProducerMoq) OutputCalls() []struct { +} { + var calls []struct { + } + mock.lockOutput.RLock() + calls = mock.calls.Output + mock.lockOutput.RUnlock() + return calls +} + +// ResetOutputCalls reset all the calls that were made to Output. +func (mock *AsyncProducerMoq) ResetOutputCalls() { + mock.lockOutput.Lock() + mock.calls.Output = nil + mock.lockOutput.Unlock() +} + +// Whatever calls WhateverFunc. +func (mock *AsyncProducerMoq) Whatever() chan bool { + if mock.WhateverFunc == nil { + panic("AsyncProducerMoq.WhateverFunc: method is nil but AsyncProducer.Whatever was just called") + } + callInfo := struct { + }{} + mock.lockWhatever.Lock() + mock.calls.Whatever = append(mock.calls.Whatever, callInfo) + mock.lockWhatever.Unlock() + return mock.WhateverFunc() +} + +// WhateverCalls gets all the calls that were made to Whatever. +// Check the length with: +// +// len(mockedAsyncProducer.WhateverCalls()) +func (mock *AsyncProducerMoq) WhateverCalls() []struct { +} { + var calls []struct { + } + mock.lockWhatever.RLock() + calls = mock.calls.Whatever + mock.lockWhatever.RUnlock() + return calls +} + +// ResetWhateverCalls reset all the calls that were made to Whatever. +func (mock *AsyncProducerMoq) ResetWhateverCalls() { + mock.lockWhatever.Lock() + mock.calls.Whatever = nil + mock.lockWhatever.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *AsyncProducerMoq) ResetCalls() { + mock.lockInput.Lock() + mock.calls.Input = nil + mock.lockInput.Unlock() + + mock.lockOutput.Lock() + mock.calls.Output = nil + mock.lockOutput.Unlock() + + mock.lockWhatever.Lock() + mock.calls.Whatever = nil + mock.lockWhatever.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go new file mode 100644 index 00000000..8706bd56 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that BlankMoq does implement Blank. +// If this is not the case, regenerate this file with moq. +var _ Blank = &BlankMoq{} + +// BlankMoq is a mock implementation of Blank. +// +// func TestSomethingThatUsesBlank(t *testing.T) { +// +// // make and configure a mocked Blank +// mockedBlank := &BlankMoq{ +// CreateFunc: func(x interface{}) error { +// panic("mock out the Create method") +// }, +// } +// +// // use mockedBlank in code that requires Blank +// // and then make assertions. +// +// } +type BlankMoq struct { + // CreateFunc mocks the Create method. + CreateFunc func(x interface{}) error + + // calls tracks calls to the methods. + calls struct { + // Create holds details about calls to the Create method. + Create []struct { + // X is the x argument value. + X interface{} + } + } + lockCreate sync.RWMutex +} + +// Create calls CreateFunc. +func (mock *BlankMoq) Create(x interface{}) error { + if mock.CreateFunc == nil { + panic("BlankMoq.CreateFunc: method is nil but Blank.Create was just called") + } + callInfo := struct { + X interface{} + }{ + X: x, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(x) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedBlank.CreateCalls()) +func (mock *BlankMoq) CreateCalls() []struct { + X interface{} +} { + var calls []struct { + X interface{} + } + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// ResetCreateCalls reset all the calls that were made to Create. +func (mock *BlankMoq) ResetCreateCalls() { + mock.lockCreate.Lock() + mock.calls.Create = nil + mock.lockCreate.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *BlankMoq) ResetCalls() { + mock.lockCreate.Lock() + mock.calls.Create = nil + mock.lockCreate.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go new file mode 100644 index 00000000..cb171f7f --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go @@ -0,0 +1,136 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that ConsulLockMoq does implement ConsulLock. +// If this is not the case, regenerate this file with moq. +var _ ConsulLock = &ConsulLockMoq{} + +// ConsulLockMoq is a mock implementation of ConsulLock. +// +// func TestSomethingThatUsesConsulLock(t *testing.T) { +// +// // make and configure a mocked ConsulLock +// mockedConsulLock := &ConsulLockMoq{ +// LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { +// panic("mock out the Lock method") +// }, +// UnlockFunc: func() error { +// panic("mock out the Unlock method") +// }, +// } +// +// // use mockedConsulLock in code that requires ConsulLock +// // and then make assertions. +// +// } +type ConsulLockMoq struct { + // LockFunc mocks the Lock method. + LockFunc func(valCh <-chan struct{}) (<-chan struct{}, error) + + // UnlockFunc mocks the Unlock method. + UnlockFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Lock holds details about calls to the Lock method. + Lock []struct { + // ValCh is the valCh argument value. + ValCh <-chan struct{} + } + // Unlock holds details about calls to the Unlock method. + Unlock []struct { + } + } + lockLock sync.RWMutex + lockUnlock sync.RWMutex +} + +// Lock calls LockFunc. +func (mock *ConsulLockMoq) Lock(valCh <-chan struct{}) (<-chan struct{}, error) { + if mock.LockFunc == nil { + panic("ConsulLockMoq.LockFunc: method is nil but ConsulLock.Lock was just called") + } + callInfo := struct { + ValCh <-chan struct{} + }{ + ValCh: valCh, + } + mock.lockLock.Lock() + mock.calls.Lock = append(mock.calls.Lock, callInfo) + mock.lockLock.Unlock() + return mock.LockFunc(valCh) +} + +// LockCalls gets all the calls that were made to Lock. +// Check the length with: +// +// len(mockedConsulLock.LockCalls()) +func (mock *ConsulLockMoq) LockCalls() []struct { + ValCh <-chan struct{} +} { + var calls []struct { + ValCh <-chan struct{} + } + mock.lockLock.RLock() + calls = mock.calls.Lock + mock.lockLock.RUnlock() + return calls +} + +// ResetLockCalls reset all the calls that were made to Lock. +func (mock *ConsulLockMoq) ResetLockCalls() { + mock.lockLock.Lock() + mock.calls.Lock = nil + mock.lockLock.Unlock() +} + +// Unlock calls UnlockFunc. +func (mock *ConsulLockMoq) Unlock() error { + if mock.UnlockFunc == nil { + panic("ConsulLockMoq.UnlockFunc: method is nil but ConsulLock.Unlock was just called") + } + callInfo := struct { + }{} + mock.lockUnlock.Lock() + mock.calls.Unlock = append(mock.calls.Unlock, callInfo) + mock.lockUnlock.Unlock() + return mock.UnlockFunc() +} + +// UnlockCalls gets all the calls that were made to Unlock. +// Check the length with: +// +// len(mockedConsulLock.UnlockCalls()) +func (mock *ConsulLockMoq) UnlockCalls() []struct { +} { + var calls []struct { + } + mock.lockUnlock.RLock() + calls = mock.calls.Unlock + mock.lockUnlock.RUnlock() + return calls +} + +// ResetUnlockCalls reset all the calls that were made to Unlock. +func (mock *ConsulLockMoq) ResetUnlockCalls() { + mock.lockUnlock.Lock() + mock.calls.Unlock = nil + mock.lockUnlock.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ConsulLockMoq) ResetCalls() { + mock.lockLock.Lock() + mock.calls.Lock = nil + mock.lockLock.Unlock() + + mock.lockUnlock.Lock() + mock.calls.Unlock = nil + mock.lockUnlock.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go new file mode 100644 index 00000000..ad3c70cb --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go @@ -0,0 +1,83 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that EmbeddedGetMoq does implement EmbeddedGet. +// If this is not the case, regenerate this file with moq. +var _ EmbeddedGet[int] = &EmbeddedGetMoq[int]{} + +// EmbeddedGetMoq is a mock implementation of EmbeddedGet. +// +// func TestSomethingThatUsesEmbeddedGet(t *testing.T) { +// +// // make and configure a mocked EmbeddedGet +// mockedEmbeddedGet := &EmbeddedGetMoq{ +// GetFunc: func() T { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedEmbeddedGet in code that requires EmbeddedGet +// // and then make assertions. +// +// } +type EmbeddedGetMoq[T constraints.Signed] struct { + // GetFunc mocks the Get method. + GetFunc func() T + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *EmbeddedGetMoq[T]) Get() T { + if mock.GetFunc == nil { + panic("EmbeddedGetMoq.GetFunc: method is nil but EmbeddedGet.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedEmbeddedGet.GetCalls()) +func (mock *EmbeddedGetMoq[T]) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *EmbeddedGetMoq[T]) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *EmbeddedGetMoq[T]) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go new file mode 100644 index 00000000..421cdd63 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go @@ -0,0 +1,139 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "net/http" + "sync" + + my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" +) + +// Ensure, that ExampleMoq does implement Example. +// If this is not the case, regenerate this file with moq. +var _ Example = &ExampleMoq{} + +// ExampleMoq is a mock implementation of Example. +// +// func TestSomethingThatUsesExample(t *testing.T) { +// +// // make and configure a mocked Example +// mockedExample := &ExampleMoq{ +// AFunc: func() http.Flusher { +// panic("mock out the A method") +// }, +// BFunc: func(fixtureshttp string) my_http.MyStruct { +// panic("mock out the B method") +// }, +// } +// +// // use mockedExample in code that requires Example +// // and then make assertions. +// +// } +type ExampleMoq struct { + // AFunc mocks the A method. + AFunc func() http.Flusher + + // BFunc mocks the B method. + BFunc func(fixtureshttp string) my_http.MyStruct + + // calls tracks calls to the methods. + calls struct { + // A holds details about calls to the A method. + A []struct { + } + // B holds details about calls to the B method. + B []struct { + // Fixtureshttp is the fixtureshttp argument value. + Fixtureshttp string + } + } + lockA sync.RWMutex + lockB sync.RWMutex +} + +// A calls AFunc. +func (mock *ExampleMoq) A() http.Flusher { + if mock.AFunc == nil { + panic("ExampleMoq.AFunc: method is nil but Example.A was just called") + } + callInfo := struct { + }{} + mock.lockA.Lock() + mock.calls.A = append(mock.calls.A, callInfo) + mock.lockA.Unlock() + return mock.AFunc() +} + +// ACalls gets all the calls that were made to A. +// Check the length with: +// +// len(mockedExample.ACalls()) +func (mock *ExampleMoq) ACalls() []struct { +} { + var calls []struct { + } + mock.lockA.RLock() + calls = mock.calls.A + mock.lockA.RUnlock() + return calls +} + +// ResetACalls reset all the calls that were made to A. +func (mock *ExampleMoq) ResetACalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() +} + +// B calls BFunc. +func (mock *ExampleMoq) B(fixtureshttp string) my_http.MyStruct { + if mock.BFunc == nil { + panic("ExampleMoq.BFunc: method is nil but Example.B was just called") + } + callInfo := struct { + Fixtureshttp string + }{ + Fixtureshttp: fixtureshttp, + } + mock.lockB.Lock() + mock.calls.B = append(mock.calls.B, callInfo) + mock.lockB.Unlock() + return mock.BFunc(fixtureshttp) +} + +// BCalls gets all the calls that were made to B. +// Check the length with: +// +// len(mockedExample.BCalls()) +func (mock *ExampleMoq) BCalls() []struct { + Fixtureshttp string +} { + var calls []struct { + Fixtureshttp string + } + mock.lockB.RLock() + calls = mock.calls.B + mock.lockB.RUnlock() + return calls +} + +// ResetBCalls reset all the calls that were made to B. +func (mock *ExampleMoq) ResetBCalls() { + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ExampleMoq) ResetCalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() + + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go new file mode 100644 index 00000000..f5532bdc --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go @@ -0,0 +1,319 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that ExpecterMoq does implement Expecter. +// If this is not the case, regenerate this file with moq. +var _ Expecter = &ExpecterMoq{} + +// ExpecterMoq is a mock implementation of Expecter. +// +// func TestSomethingThatUsesExpecter(t *testing.T) { +// +// // make and configure a mocked Expecter +// mockedExpecter := &ExpecterMoq{ +// ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { +// panic("mock out the ManyArgsReturns method") +// }, +// NoArgFunc: func() string { +// panic("mock out the NoArg method") +// }, +// NoReturnFunc: func(str string) { +// panic("mock out the NoReturn method") +// }, +// VariadicFunc: func(ints ...int) error { +// panic("mock out the Variadic method") +// }, +// VariadicManyFunc: func(i int, a string, intfs ...interface{}) error { +// panic("mock out the VariadicMany method") +// }, +// } +// +// // use mockedExpecter in code that requires Expecter +// // and then make assertions. +// +// } +type ExpecterMoq struct { + // ManyArgsReturnsFunc mocks the ManyArgsReturns method. + ManyArgsReturnsFunc func(str string, i int) ([]string, error) + + // NoArgFunc mocks the NoArg method. + NoArgFunc func() string + + // NoReturnFunc mocks the NoReturn method. + NoReturnFunc func(str string) + + // VariadicFunc mocks the Variadic method. + VariadicFunc func(ints ...int) error + + // VariadicManyFunc mocks the VariadicMany method. + VariadicManyFunc func(i int, a string, intfs ...interface{}) error + + // calls tracks calls to the methods. + calls struct { + // ManyArgsReturns holds details about calls to the ManyArgsReturns method. + ManyArgsReturns []struct { + // Str is the str argument value. + Str string + // I is the i argument value. + I int + } + // NoArg holds details about calls to the NoArg method. + NoArg []struct { + } + // NoReturn holds details about calls to the NoReturn method. + NoReturn []struct { + // Str is the str argument value. + Str string + } + // Variadic holds details about calls to the Variadic method. + Variadic []struct { + // Ints is the ints argument value. + Ints []int + } + // VariadicMany holds details about calls to the VariadicMany method. + VariadicMany []struct { + // I is the i argument value. + I int + // A is the a argument value. + A string + // Intfs is the intfs argument value. + Intfs []interface{} + } + } + lockManyArgsReturns sync.RWMutex + lockNoArg sync.RWMutex + lockNoReturn sync.RWMutex + lockVariadic sync.RWMutex + lockVariadicMany sync.RWMutex +} + +// ManyArgsReturns calls ManyArgsReturnsFunc. +func (mock *ExpecterMoq) ManyArgsReturns(str string, i int) ([]string, error) { + if mock.ManyArgsReturnsFunc == nil { + panic("ExpecterMoq.ManyArgsReturnsFunc: method is nil but Expecter.ManyArgsReturns was just called") + } + callInfo := struct { + Str string + I int + }{ + Str: str, + I: i, + } + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = append(mock.calls.ManyArgsReturns, callInfo) + mock.lockManyArgsReturns.Unlock() + return mock.ManyArgsReturnsFunc(str, i) +} + +// ManyArgsReturnsCalls gets all the calls that were made to ManyArgsReturns. +// Check the length with: +// +// len(mockedExpecter.ManyArgsReturnsCalls()) +func (mock *ExpecterMoq) ManyArgsReturnsCalls() []struct { + Str string + I int +} { + var calls []struct { + Str string + I int + } + mock.lockManyArgsReturns.RLock() + calls = mock.calls.ManyArgsReturns + mock.lockManyArgsReturns.RUnlock() + return calls +} + +// ResetManyArgsReturnsCalls reset all the calls that were made to ManyArgsReturns. +func (mock *ExpecterMoq) ResetManyArgsReturnsCalls() { + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = nil + mock.lockManyArgsReturns.Unlock() +} + +// NoArg calls NoArgFunc. +func (mock *ExpecterMoq) NoArg() string { + if mock.NoArgFunc == nil { + panic("ExpecterMoq.NoArgFunc: method is nil but Expecter.NoArg was just called") + } + callInfo := struct { + }{} + mock.lockNoArg.Lock() + mock.calls.NoArg = append(mock.calls.NoArg, callInfo) + mock.lockNoArg.Unlock() + return mock.NoArgFunc() +} + +// NoArgCalls gets all the calls that were made to NoArg. +// Check the length with: +// +// len(mockedExpecter.NoArgCalls()) +func (mock *ExpecterMoq) NoArgCalls() []struct { +} { + var calls []struct { + } + mock.lockNoArg.RLock() + calls = mock.calls.NoArg + mock.lockNoArg.RUnlock() + return calls +} + +// ResetNoArgCalls reset all the calls that were made to NoArg. +func (mock *ExpecterMoq) ResetNoArgCalls() { + mock.lockNoArg.Lock() + mock.calls.NoArg = nil + mock.lockNoArg.Unlock() +} + +// NoReturn calls NoReturnFunc. +func (mock *ExpecterMoq) NoReturn(str string) { + if mock.NoReturnFunc == nil { + panic("ExpecterMoq.NoReturnFunc: method is nil but Expecter.NoReturn was just called") + } + callInfo := struct { + Str string + }{ + Str: str, + } + mock.lockNoReturn.Lock() + mock.calls.NoReturn = append(mock.calls.NoReturn, callInfo) + mock.lockNoReturn.Unlock() + mock.NoReturnFunc(str) +} + +// NoReturnCalls gets all the calls that were made to NoReturn. +// Check the length with: +// +// len(mockedExpecter.NoReturnCalls()) +func (mock *ExpecterMoq) NoReturnCalls() []struct { + Str string +} { + var calls []struct { + Str string + } + mock.lockNoReturn.RLock() + calls = mock.calls.NoReturn + mock.lockNoReturn.RUnlock() + return calls +} + +// ResetNoReturnCalls reset all the calls that were made to NoReturn. +func (mock *ExpecterMoq) ResetNoReturnCalls() { + mock.lockNoReturn.Lock() + mock.calls.NoReturn = nil + mock.lockNoReturn.Unlock() +} + +// Variadic calls VariadicFunc. +func (mock *ExpecterMoq) Variadic(ints ...int) error { + if mock.VariadicFunc == nil { + panic("ExpecterMoq.VariadicFunc: method is nil but Expecter.Variadic was just called") + } + callInfo := struct { + Ints []int + }{ + Ints: ints, + } + mock.lockVariadic.Lock() + mock.calls.Variadic = append(mock.calls.Variadic, callInfo) + mock.lockVariadic.Unlock() + return mock.VariadicFunc(ints...) +} + +// VariadicCalls gets all the calls that were made to Variadic. +// Check the length with: +// +// len(mockedExpecter.VariadicCalls()) +func (mock *ExpecterMoq) VariadicCalls() []struct { + Ints []int +} { + var calls []struct { + Ints []int + } + mock.lockVariadic.RLock() + calls = mock.calls.Variadic + mock.lockVariadic.RUnlock() + return calls +} + +// ResetVariadicCalls reset all the calls that were made to Variadic. +func (mock *ExpecterMoq) ResetVariadicCalls() { + mock.lockVariadic.Lock() + mock.calls.Variadic = nil + mock.lockVariadic.Unlock() +} + +// VariadicMany calls VariadicManyFunc. +func (mock *ExpecterMoq) VariadicMany(i int, a string, intfs ...interface{}) error { + if mock.VariadicManyFunc == nil { + panic("ExpecterMoq.VariadicManyFunc: method is nil but Expecter.VariadicMany was just called") + } + callInfo := struct { + I int + A string + Intfs []interface{} + }{ + I: i, + A: a, + Intfs: intfs, + } + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = append(mock.calls.VariadicMany, callInfo) + mock.lockVariadicMany.Unlock() + return mock.VariadicManyFunc(i, a, intfs...) +} + +// VariadicManyCalls gets all the calls that were made to VariadicMany. +// Check the length with: +// +// len(mockedExpecter.VariadicManyCalls()) +func (mock *ExpecterMoq) VariadicManyCalls() []struct { + I int + A string + Intfs []interface{} +} { + var calls []struct { + I int + A string + Intfs []interface{} + } + mock.lockVariadicMany.RLock() + calls = mock.calls.VariadicMany + mock.lockVariadicMany.RUnlock() + return calls +} + +// ResetVariadicManyCalls reset all the calls that were made to VariadicMany. +func (mock *ExpecterMoq) ResetVariadicManyCalls() { + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = nil + mock.lockVariadicMany.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ExpecterMoq) ResetCalls() { + mock.lockManyArgsReturns.Lock() + mock.calls.ManyArgsReturns = nil + mock.lockManyArgsReturns.Unlock() + + mock.lockNoArg.Lock() + mock.calls.NoArg = nil + mock.lockNoArg.Unlock() + + mock.lockNoReturn.Lock() + mock.calls.NoReturn = nil + mock.lockNoReturn.Unlock() + + mock.lockVariadic.Lock() + mock.calls.Variadic = nil + mock.lockVariadic.Unlock() + + mock.lockVariadicMany.Lock() + mock.calls.VariadicMany = nil + mock.lockVariadicMany.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go new file mode 100644 index 00000000..0e5ffc2a --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go @@ -0,0 +1,198 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that FooerMoq does implement Fooer. +// If this is not the case, regenerate this file with moq. +var _ Fooer = &FooerMoq{} + +// FooerMoq is a mock implementation of Fooer. +// +// func TestSomethingThatUsesFooer(t *testing.T) { +// +// // make and configure a mocked Fooer +// mockedFooer := &FooerMoq{ +// BarFunc: func(f func([]int)) { +// panic("mock out the Bar method") +// }, +// BazFunc: func(path string) func(x string) string { +// panic("mock out the Baz method") +// }, +// FooFunc: func(f func(x string) string) error { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedFooer in code that requires Fooer +// // and then make assertions. +// +// } +type FooerMoq struct { + // BarFunc mocks the Bar method. + BarFunc func(f func([]int)) + + // BazFunc mocks the Baz method. + BazFunc func(path string) func(x string) string + + // FooFunc mocks the Foo method. + FooFunc func(f func(x string) string) error + + // calls tracks calls to the methods. + calls struct { + // Bar holds details about calls to the Bar method. + Bar []struct { + // F is the f argument value. + F func([]int) + } + // Baz holds details about calls to the Baz method. + Baz []struct { + // Path is the path argument value. + Path string + } + // Foo holds details about calls to the Foo method. + Foo []struct { + // F is the f argument value. + F func(x string) string + } + } + lockBar sync.RWMutex + lockBaz sync.RWMutex + lockFoo sync.RWMutex +} + +// Bar calls BarFunc. +func (mock *FooerMoq) Bar(f func([]int)) { + if mock.BarFunc == nil { + panic("FooerMoq.BarFunc: method is nil but Fooer.Bar was just called") + } + callInfo := struct { + F func([]int) + }{ + F: f, + } + mock.lockBar.Lock() + mock.calls.Bar = append(mock.calls.Bar, callInfo) + mock.lockBar.Unlock() + mock.BarFunc(f) +} + +// BarCalls gets all the calls that were made to Bar. +// Check the length with: +// +// len(mockedFooer.BarCalls()) +func (mock *FooerMoq) BarCalls() []struct { + F func([]int) +} { + var calls []struct { + F func([]int) + } + mock.lockBar.RLock() + calls = mock.calls.Bar + mock.lockBar.RUnlock() + return calls +} + +// ResetBarCalls reset all the calls that were made to Bar. +func (mock *FooerMoq) ResetBarCalls() { + mock.lockBar.Lock() + mock.calls.Bar = nil + mock.lockBar.Unlock() +} + +// Baz calls BazFunc. +func (mock *FooerMoq) Baz(path string) func(x string) string { + if mock.BazFunc == nil { + panic("FooerMoq.BazFunc: method is nil but Fooer.Baz was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockBaz.Lock() + mock.calls.Baz = append(mock.calls.Baz, callInfo) + mock.lockBaz.Unlock() + return mock.BazFunc(path) +} + +// BazCalls gets all the calls that were made to Baz. +// Check the length with: +// +// len(mockedFooer.BazCalls()) +func (mock *FooerMoq) BazCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockBaz.RLock() + calls = mock.calls.Baz + mock.lockBaz.RUnlock() + return calls +} + +// ResetBazCalls reset all the calls that were made to Baz. +func (mock *FooerMoq) ResetBazCalls() { + mock.lockBaz.Lock() + mock.calls.Baz = nil + mock.lockBaz.Unlock() +} + +// Foo calls FooFunc. +func (mock *FooerMoq) Foo(f func(x string) string) error { + if mock.FooFunc == nil { + panic("FooerMoq.FooFunc: method is nil but Fooer.Foo was just called") + } + callInfo := struct { + F func(x string) string + }{ + F: f, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + return mock.FooFunc(f) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedFooer.FooCalls()) +func (mock *FooerMoq) FooCalls() []struct { + F func(x string) string +} { + var calls []struct { + F func(x string) string + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *FooerMoq) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *FooerMoq) ResetCalls() { + mock.lockBar.Lock() + mock.calls.Bar = nil + mock.lockBar.Unlock() + + mock.lockBaz.Lock() + mock.calls.Baz = nil + mock.lockBaz.Unlock() + + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go new file mode 100644 index 00000000..024f658e --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that FuncArgsCollisionMoq does implement FuncArgsCollision. +// If this is not the case, regenerate this file with moq. +var _ FuncArgsCollision = &FuncArgsCollisionMoq{} + +// FuncArgsCollisionMoq is a mock implementation of FuncArgsCollision. +// +// func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { +// +// // make and configure a mocked FuncArgsCollision +// mockedFuncArgsCollision := &FuncArgsCollisionMoq{ +// FooFunc: func(ret interface{}) error { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedFuncArgsCollision in code that requires FuncArgsCollision +// // and then make assertions. +// +// } +type FuncArgsCollisionMoq struct { + // FooFunc mocks the Foo method. + FooFunc func(ret interface{}) error + + // calls tracks calls to the methods. + calls struct { + // Foo holds details about calls to the Foo method. + Foo []struct { + // Ret is the ret argument value. + Ret interface{} + } + } + lockFoo sync.RWMutex +} + +// Foo calls FooFunc. +func (mock *FuncArgsCollisionMoq) Foo(ret interface{}) error { + if mock.FooFunc == nil { + panic("FuncArgsCollisionMoq.FooFunc: method is nil but FuncArgsCollision.Foo was just called") + } + callInfo := struct { + Ret interface{} + }{ + Ret: ret, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + return mock.FooFunc(ret) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedFuncArgsCollision.FooCalls()) +func (mock *FuncArgsCollisionMoq) FooCalls() []struct { + Ret interface{} +} { + var calls []struct { + Ret interface{} + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *FuncArgsCollisionMoq) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *FuncArgsCollisionMoq) ResetCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go new file mode 100644 index 00000000..5caf521d --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go @@ -0,0 +1,83 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// Ensure, that GetGenericMoq does implement GetGeneric. +// If this is not the case, regenerate this file with moq. +var _ GetGeneric[int] = &GetGenericMoq[int]{} + +// GetGenericMoq is a mock implementation of GetGeneric. +// +// func TestSomethingThatUsesGetGeneric(t *testing.T) { +// +// // make and configure a mocked GetGeneric +// mockedGetGeneric := &GetGenericMoq{ +// GetFunc: func() T { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedGetGeneric in code that requires GetGeneric +// // and then make assertions. +// +// } +type GetGenericMoq[T constraints.Integer] struct { + // GetFunc mocks the Get method. + GetFunc func() T + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *GetGenericMoq[T]) Get() T { + if mock.GetFunc == nil { + panic("GetGenericMoq.GetFunc: method is nil but GetGeneric.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedGetGeneric.GetCalls()) +func (mock *GetGenericMoq[T]) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *GetGenericMoq[T]) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *GetGenericMoq[T]) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go new file mode 100644 index 00000000..52bb5c9c --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go @@ -0,0 +1,81 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that GetIntMoq does implement GetInt. +// If this is not the case, regenerate this file with moq. +var _ GetInt = &GetIntMoq{} + +// GetIntMoq is a mock implementation of GetInt. +// +// func TestSomethingThatUsesGetInt(t *testing.T) { +// +// // make and configure a mocked GetInt +// mockedGetInt := &GetIntMoq{ +// GetFunc: func() int { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedGetInt in code that requires GetInt +// // and then make assertions. +// +// } +type GetIntMoq struct { + // GetFunc mocks the Get method. + GetFunc func() int + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *GetIntMoq) Get() int { + if mock.GetFunc == nil { + panic("GetIntMoq.GetFunc: method is nil but GetInt.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedGetInt.GetCalls()) +func (mock *GetIntMoq) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *GetIntMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *GetIntMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go new file mode 100644 index 00000000..533e6e59 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go @@ -0,0 +1,139 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "net/http" + "sync" + + my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" +) + +// Ensure, that HasConflictingNestedImportsMoq does implement HasConflictingNestedImports. +// If this is not the case, regenerate this file with moq. +var _ HasConflictingNestedImports = &HasConflictingNestedImportsMoq{} + +// HasConflictingNestedImportsMoq is a mock implementation of HasConflictingNestedImports. +// +// func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { +// +// // make and configure a mocked HasConflictingNestedImports +// mockedHasConflictingNestedImports := &HasConflictingNestedImportsMoq{ +// GetFunc: func(path string) (http.Response, error) { +// panic("mock out the Get method") +// }, +// ZFunc: func() my_http.MyStruct { +// panic("mock out the Z method") +// }, +// } +// +// // use mockedHasConflictingNestedImports in code that requires HasConflictingNestedImports +// // and then make assertions. +// +// } +type HasConflictingNestedImportsMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (http.Response, error) + + // ZFunc mocks the Z method. + ZFunc func() my_http.MyStruct + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Z holds details about calls to the Z method. + Z []struct { + } + } + lockGet sync.RWMutex + lockZ sync.RWMutex +} + +// Get calls GetFunc. +func (mock *HasConflictingNestedImportsMoq) Get(path string) (http.Response, error) { + if mock.GetFunc == nil { + panic("HasConflictingNestedImportsMoq.GetFunc: method is nil but HasConflictingNestedImports.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedHasConflictingNestedImports.GetCalls()) +func (mock *HasConflictingNestedImportsMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *HasConflictingNestedImportsMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// Z calls ZFunc. +func (mock *HasConflictingNestedImportsMoq) Z() my_http.MyStruct { + if mock.ZFunc == nil { + panic("HasConflictingNestedImportsMoq.ZFunc: method is nil but HasConflictingNestedImports.Z was just called") + } + callInfo := struct { + }{} + mock.lockZ.Lock() + mock.calls.Z = append(mock.calls.Z, callInfo) + mock.lockZ.Unlock() + return mock.ZFunc() +} + +// ZCalls gets all the calls that were made to Z. +// Check the length with: +// +// len(mockedHasConflictingNestedImports.ZCalls()) +func (mock *HasConflictingNestedImportsMoq) ZCalls() []struct { +} { + var calls []struct { + } + mock.lockZ.RLock() + calls = mock.calls.Z + mock.lockZ.RUnlock() + return calls +} + +// ResetZCalls reset all the calls that were made to Z. +func (mock *HasConflictingNestedImportsMoq) ResetZCalls() { + mock.lockZ.Lock() + mock.calls.Z = nil + mock.lockZ.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *HasConflictingNestedImportsMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockZ.Lock() + mock.calls.Z = nil + mock.lockZ.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go new file mode 100644 index 00000000..2910ead4 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go @@ -0,0 +1,187 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + fixtures "github.com/vektra/mockery/v2/pkg/fixtures" + redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" +) + +// Ensure, that ImportsSameAsPackageMoq does implement ImportsSameAsPackage. +// If this is not the case, regenerate this file with moq. +var _ ImportsSameAsPackage = &ImportsSameAsPackageMoq{} + +// ImportsSameAsPackageMoq is a mock implementation of ImportsSameAsPackage. +// +// func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { +// +// // make and configure a mocked ImportsSameAsPackage +// mockedImportsSameAsPackage := &ImportsSameAsPackageMoq{ +// AFunc: func() redefinedtypeb.B { +// panic("mock out the A method") +// }, +// BFunc: func() fixtures.KeyManager { +// panic("mock out the B method") +// }, +// CFunc: func(c fixtures.C) { +// panic("mock out the C method") +// }, +// } +// +// // use mockedImportsSameAsPackage in code that requires ImportsSameAsPackage +// // and then make assertions. +// +// } +type ImportsSameAsPackageMoq struct { + // AFunc mocks the A method. + AFunc func() redefinedtypeb.B + + // BFunc mocks the B method. + BFunc func() fixtures.KeyManager + + // CFunc mocks the C method. + CFunc func(c fixtures.C) + + // calls tracks calls to the methods. + calls struct { + // A holds details about calls to the A method. + A []struct { + } + // B holds details about calls to the B method. + B []struct { + } + // C holds details about calls to the C method. + C []struct { + // C is the c argument value. + C fixtures.C + } + } + lockA sync.RWMutex + lockB sync.RWMutex + lockC sync.RWMutex +} + +// A calls AFunc. +func (mock *ImportsSameAsPackageMoq) A() redefinedtypeb.B { + if mock.AFunc == nil { + panic("ImportsSameAsPackageMoq.AFunc: method is nil but ImportsSameAsPackage.A was just called") + } + callInfo := struct { + }{} + mock.lockA.Lock() + mock.calls.A = append(mock.calls.A, callInfo) + mock.lockA.Unlock() + return mock.AFunc() +} + +// ACalls gets all the calls that were made to A. +// Check the length with: +// +// len(mockedImportsSameAsPackage.ACalls()) +func (mock *ImportsSameAsPackageMoq) ACalls() []struct { +} { + var calls []struct { + } + mock.lockA.RLock() + calls = mock.calls.A + mock.lockA.RUnlock() + return calls +} + +// ResetACalls reset all the calls that were made to A. +func (mock *ImportsSameAsPackageMoq) ResetACalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() +} + +// B calls BFunc. +func (mock *ImportsSameAsPackageMoq) B() fixtures.KeyManager { + if mock.BFunc == nil { + panic("ImportsSameAsPackageMoq.BFunc: method is nil but ImportsSameAsPackage.B was just called") + } + callInfo := struct { + }{} + mock.lockB.Lock() + mock.calls.B = append(mock.calls.B, callInfo) + mock.lockB.Unlock() + return mock.BFunc() +} + +// BCalls gets all the calls that were made to B. +// Check the length with: +// +// len(mockedImportsSameAsPackage.BCalls()) +func (mock *ImportsSameAsPackageMoq) BCalls() []struct { +} { + var calls []struct { + } + mock.lockB.RLock() + calls = mock.calls.B + mock.lockB.RUnlock() + return calls +} + +// ResetBCalls reset all the calls that were made to B. +func (mock *ImportsSameAsPackageMoq) ResetBCalls() { + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() +} + +// C calls CFunc. +func (mock *ImportsSameAsPackageMoq) C(c fixtures.C) { + if mock.CFunc == nil { + panic("ImportsSameAsPackageMoq.CFunc: method is nil but ImportsSameAsPackage.C was just called") + } + callInfo := struct { + C fixtures.C + }{ + C: c, + } + mock.lockC.Lock() + mock.calls.C = append(mock.calls.C, callInfo) + mock.lockC.Unlock() + mock.CFunc(c) +} + +// CCalls gets all the calls that were made to C. +// Check the length with: +// +// len(mockedImportsSameAsPackage.CCalls()) +func (mock *ImportsSameAsPackageMoq) CCalls() []struct { + C fixtures.C +} { + var calls []struct { + C fixtures.C + } + mock.lockC.RLock() + calls = mock.calls.C + mock.lockC.RUnlock() + return calls +} + +// ResetCCalls reset all the calls that were made to C. +func (mock *ImportsSameAsPackageMoq) ResetCCalls() { + mock.lockC.Lock() + mock.calls.C = nil + mock.lockC.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *ImportsSameAsPackageMoq) ResetCalls() { + mock.lockA.Lock() + mock.calls.A = nil + mock.lockA.Unlock() + + mock.lockB.Lock() + mock.calls.B = nil + mock.lockB.Unlock() + + mock.lockC.Lock() + mock.calls.C = nil + mock.lockC.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go new file mode 100644 index 00000000..14936130 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go @@ -0,0 +1,96 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that KeyManagerMoq does implement KeyManager. +// If this is not the case, regenerate this file with moq. +var _ KeyManager = &KeyManagerMoq{} + +// KeyManagerMoq is a mock implementation of KeyManager. +// +// func TestSomethingThatUsesKeyManager(t *testing.T) { +// +// // make and configure a mocked KeyManager +// mockedKeyManager := &KeyManagerMoq{ +// GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { +// panic("mock out the GetKey method") +// }, +// } +// +// // use mockedKeyManager in code that requires KeyManager +// // and then make assertions. +// +// } +type KeyManagerMoq struct { + // GetKeyFunc mocks the GetKey method. + GetKeyFunc func(s string, v uint16) ([]byte, *test.Err) + + // calls tracks calls to the methods. + calls struct { + // GetKey holds details about calls to the GetKey method. + GetKey []struct { + // S is the s argument value. + S string + // V is the v argument value. + V uint16 + } + } + lockGetKey sync.RWMutex +} + +// GetKey calls GetKeyFunc. +func (mock *KeyManagerMoq) GetKey(s string, v uint16) ([]byte, *test.Err) { + if mock.GetKeyFunc == nil { + panic("KeyManagerMoq.GetKeyFunc: method is nil but KeyManager.GetKey was just called") + } + callInfo := struct { + S string + V uint16 + }{ + S: s, + V: v, + } + mock.lockGetKey.Lock() + mock.calls.GetKey = append(mock.calls.GetKey, callInfo) + mock.lockGetKey.Unlock() + return mock.GetKeyFunc(s, v) +} + +// GetKeyCalls gets all the calls that were made to GetKey. +// Check the length with: +// +// len(mockedKeyManager.GetKeyCalls()) +func (mock *KeyManagerMoq) GetKeyCalls() []struct { + S string + V uint16 +} { + var calls []struct { + S string + V uint16 + } + mock.lockGetKey.RLock() + calls = mock.calls.GetKey + mock.lockGetKey.RUnlock() + return calls +} + +// ResetGetKeyCalls reset all the calls that were made to GetKey. +func (mock *KeyManagerMoq) ResetGetKeyCalls() { + mock.lockGetKey.Lock() + mock.calls.GetKey = nil + mock.lockGetKey.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *KeyManagerMoq) ResetCalls() { + mock.lockGetKey.Lock() + mock.calls.GetKey = nil + mock.lockGetKey.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go new file mode 100644 index 00000000..456df057 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that MapFuncMoq does implement MapFunc. +// If this is not the case, regenerate this file with moq. +var _ MapFunc = &MapFuncMoq{} + +// MapFuncMoq is a mock implementation of MapFunc. +// +// func TestSomethingThatUsesMapFunc(t *testing.T) { +// +// // make and configure a mocked MapFunc +// mockedMapFunc := &MapFuncMoq{ +// GetFunc: func(m map[string]func(string) string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedMapFunc in code that requires MapFunc +// // and then make assertions. +// +// } +type MapFuncMoq struct { + // GetFunc mocks the Get method. + GetFunc func(m map[string]func(string) string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // M is the m argument value. + M map[string]func(string) string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *MapFuncMoq) Get(m map[string]func(string) string) error { + if mock.GetFunc == nil { + panic("MapFuncMoq.GetFunc: method is nil but MapFunc.Get was just called") + } + callInfo := struct { + M map[string]func(string) string + }{ + M: m, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(m) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedMapFunc.GetCalls()) +func (mock *MapFuncMoq) GetCalls() []struct { + M map[string]func(string) string +} { + var calls []struct { + M map[string]func(string) string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *MapFuncMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MapFuncMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go new file mode 100644 index 00000000..9526235c --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that MapToInterfaceMoq does implement MapToInterface. +// If this is not the case, regenerate this file with moq. +var _ MapToInterface = &MapToInterfaceMoq{} + +// MapToInterfaceMoq is a mock implementation of MapToInterface. +// +// func TestSomethingThatUsesMapToInterface(t *testing.T) { +// +// // make and configure a mocked MapToInterface +// mockedMapToInterface := &MapToInterfaceMoq{ +// FooFunc: func(arg1 ...map[string]interface{}) { +// panic("mock out the Foo method") +// }, +// } +// +// // use mockedMapToInterface in code that requires MapToInterface +// // and then make assertions. +// +// } +type MapToInterfaceMoq struct { + // FooFunc mocks the Foo method. + FooFunc func(arg1 ...map[string]interface{}) + + // calls tracks calls to the methods. + calls struct { + // Foo holds details about calls to the Foo method. + Foo []struct { + // Arg1 is the arg1 argument value. + Arg1 []map[string]interface{} + } + } + lockFoo sync.RWMutex +} + +// Foo calls FooFunc. +func (mock *MapToInterfaceMoq) Foo(arg1 ...map[string]interface{}) { + if mock.FooFunc == nil { + panic("MapToInterfaceMoq.FooFunc: method is nil but MapToInterface.Foo was just called") + } + callInfo := struct { + Arg1 []map[string]interface{} + }{ + Arg1: arg1, + } + mock.lockFoo.Lock() + mock.calls.Foo = append(mock.calls.Foo, callInfo) + mock.lockFoo.Unlock() + mock.FooFunc(arg1...) +} + +// FooCalls gets all the calls that were made to Foo. +// Check the length with: +// +// len(mockedMapToInterface.FooCalls()) +func (mock *MapToInterfaceMoq) FooCalls() []struct { + Arg1 []map[string]interface{} +} { + var calls []struct { + Arg1 []map[string]interface{} + } + mock.lockFoo.RLock() + calls = mock.calls.Foo + mock.lockFoo.RUnlock() + return calls +} + +// ResetFooCalls reset all the calls that were made to Foo. +func (mock *MapToInterfaceMoq) ResetFooCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MapToInterfaceMoq) ResetCalls() { + mock.lockFoo.Lock() + mock.calls.Foo = nil + mock.lockFoo.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go new file mode 100644 index 00000000..6f83b501 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that MyReaderMoq does implement MyReader. +// If this is not the case, regenerate this file with moq. +var _ MyReader = &MyReaderMoq{} + +// MyReaderMoq is a mock implementation of MyReader. +// +// func TestSomethingThatUsesMyReader(t *testing.T) { +// +// // make and configure a mocked MyReader +// mockedMyReader := &MyReaderMoq{ +// ReadFunc: func(p []byte) (int, error) { +// panic("mock out the Read method") +// }, +// } +// +// // use mockedMyReader in code that requires MyReader +// // and then make assertions. +// +// } +type MyReaderMoq struct { + // ReadFunc mocks the Read method. + ReadFunc func(p []byte) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Read holds details about calls to the Read method. + Read []struct { + // P is the p argument value. + P []byte + } + } + lockRead sync.RWMutex +} + +// Read calls ReadFunc. +func (mock *MyReaderMoq) Read(p []byte) (int, error) { + if mock.ReadFunc == nil { + panic("MyReaderMoq.ReadFunc: method is nil but MyReader.Read was just called") + } + callInfo := struct { + P []byte + }{ + P: p, + } + mock.lockRead.Lock() + mock.calls.Read = append(mock.calls.Read, callInfo) + mock.lockRead.Unlock() + return mock.ReadFunc(p) +} + +// ReadCalls gets all the calls that were made to Read. +// Check the length with: +// +// len(mockedMyReader.ReadCalls()) +func (mock *MyReaderMoq) ReadCalls() []struct { + P []byte +} { + var calls []struct { + P []byte + } + mock.lockRead.RLock() + calls = mock.calls.Read + mock.lockRead.RUnlock() + return calls +} + +// ResetReadCalls reset all the calls that were made to Read. +func (mock *MyReaderMoq) ResetReadCalls() { + mock.lockRead.Lock() + mock.calls.Read = nil + mock.lockRead.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *MyReaderMoq) ResetCalls() { + mock.lockRead.Lock() + mock.calls.Read = nil + mock.lockRead.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go new file mode 100644 index 00000000..f279eee1 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go @@ -0,0 +1,81 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that PanicOnNoReturnValueMoq does implement PanicOnNoReturnValue. +// If this is not the case, regenerate this file with moq. +var _ PanicOnNoReturnValue = &PanicOnNoReturnValueMoq{} + +// PanicOnNoReturnValueMoq is a mock implementation of PanicOnNoReturnValue. +// +// func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { +// +// // make and configure a mocked PanicOnNoReturnValue +// mockedPanicOnNoReturnValue := &PanicOnNoReturnValueMoq{ +// DoSomethingFunc: func() string { +// panic("mock out the DoSomething method") +// }, +// } +// +// // use mockedPanicOnNoReturnValue in code that requires PanicOnNoReturnValue +// // and then make assertions. +// +// } +type PanicOnNoReturnValueMoq struct { + // DoSomethingFunc mocks the DoSomething method. + DoSomethingFunc func() string + + // calls tracks calls to the methods. + calls struct { + // DoSomething holds details about calls to the DoSomething method. + DoSomething []struct { + } + } + lockDoSomething sync.RWMutex +} + +// DoSomething calls DoSomethingFunc. +func (mock *PanicOnNoReturnValueMoq) DoSomething() string { + if mock.DoSomethingFunc == nil { + panic("PanicOnNoReturnValueMoq.DoSomethingFunc: method is nil but PanicOnNoReturnValue.DoSomething was just called") + } + callInfo := struct { + }{} + mock.lockDoSomething.Lock() + mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) + mock.lockDoSomething.Unlock() + return mock.DoSomethingFunc() +} + +// DoSomethingCalls gets all the calls that were made to DoSomething. +// Check the length with: +// +// len(mockedPanicOnNoReturnValue.DoSomethingCalls()) +func (mock *PanicOnNoReturnValueMoq) DoSomethingCalls() []struct { +} { + var calls []struct { + } + mock.lockDoSomething.RLock() + calls = mock.calls.DoSomething + mock.lockDoSomething.RUnlock() + return calls +} + +// ResetDoSomethingCalls reset all the calls that were made to DoSomething. +func (mock *PanicOnNoReturnValueMoq) ResetDoSomethingCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *PanicOnNoReturnValueMoq) ResetCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go new file mode 100644 index 00000000..3385a629 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that Requester2Moq does implement Requester2. +// If this is not the case, regenerate this file with moq. +var _ Requester2 = &Requester2Moq{} + +// Requester2Moq is a mock implementation of Requester2. +// +// func TestSomethingThatUsesRequester2(t *testing.T) { +// +// // make and configure a mocked Requester2 +// mockedRequester2 := &Requester2Moq{ +// GetFunc: func(path string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester2 in code that requires Requester2 +// // and then make assertions. +// +// } +type Requester2Moq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester2Moq) Get(path string) error { + if mock.GetFunc == nil { + panic("Requester2Moq.GetFunc: method is nil but Requester2.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester2.GetCalls()) +func (mock *Requester2Moq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester2Moq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester2Moq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go new file mode 100644 index 00000000..dab971dd --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go @@ -0,0 +1,81 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that Requester3Moq does implement Requester3. +// If this is not the case, regenerate this file with moq. +var _ Requester3 = &Requester3Moq{} + +// Requester3Moq is a mock implementation of Requester3. +// +// func TestSomethingThatUsesRequester3(t *testing.T) { +// +// // make and configure a mocked Requester3 +// mockedRequester3 := &Requester3Moq{ +// GetFunc: func() error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester3 in code that requires Requester3 +// // and then make assertions. +// +// } +type Requester3Moq struct { + // GetFunc mocks the Get method. + GetFunc func() error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester3Moq) Get() error { + if mock.GetFunc == nil { + panic("Requester3Moq.GetFunc: method is nil but Requester3.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester3.GetCalls()) +func (mock *Requester3Moq) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester3Moq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester3Moq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go new file mode 100644 index 00000000..94b960bc --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go @@ -0,0 +1,81 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that Requester4Moq does implement Requester4. +// If this is not the case, regenerate this file with moq. +var _ Requester4 = &Requester4Moq{} + +// Requester4Moq is a mock implementation of Requester4. +// +// func TestSomethingThatUsesRequester4(t *testing.T) { +// +// // make and configure a mocked Requester4 +// mockedRequester4 := &Requester4Moq{ +// GetFunc: func() { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester4 in code that requires Requester4 +// // and then make assertions. +// +// } +type Requester4Moq struct { + // GetFunc mocks the Get method. + GetFunc func() + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *Requester4Moq) Get() { + if mock.GetFunc == nil { + panic("Requester4Moq.GetFunc: method is nil but Requester4.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester4.GetCalls()) +func (mock *Requester4Moq) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *Requester4Moq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *Requester4Moq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go new file mode 100644 index 00000000..39a7a5a8 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go @@ -0,0 +1,89 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "encoding/json" + "sync" +) + +// Ensure, that RequesterArgSameAsImportMoq does implement RequesterArgSameAsImport. +// If this is not the case, regenerate this file with moq. +var _ RequesterArgSameAsImport = &RequesterArgSameAsImportMoq{} + +// RequesterArgSameAsImportMoq is a mock implementation of RequesterArgSameAsImport. +// +// func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { +// +// // make and configure a mocked RequesterArgSameAsImport +// mockedRequesterArgSameAsImport := &RequesterArgSameAsImportMoq{ +// GetFunc: func(jsonMoqParam string) *json.RawMessage { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsImport in code that requires RequesterArgSameAsImport +// // and then make assertions. +// +// } +type RequesterArgSameAsImportMoq struct { + // GetFunc mocks the Get method. + GetFunc func(jsonMoqParam string) *json.RawMessage + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // JsonMoqParam is the jsonMoqParam argument value. + JsonMoqParam string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsImportMoq) Get(jsonMoqParam string) *json.RawMessage { + if mock.GetFunc == nil { + panic("RequesterArgSameAsImportMoq.GetFunc: method is nil but RequesterArgSameAsImport.Get was just called") + } + callInfo := struct { + JsonMoqParam string + }{ + JsonMoqParam: jsonMoqParam, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(jsonMoqParam) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsImport.GetCalls()) +func (mock *RequesterArgSameAsImportMoq) GetCalls() []struct { + JsonMoqParam string +} { + var calls []struct { + JsonMoqParam string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsImportMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsImportMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go new file mode 100644 index 00000000..a4f1f291 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go @@ -0,0 +1,89 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "encoding/json" + "sync" +) + +// Ensure, that RequesterArgSameAsNamedImportMoq does implement RequesterArgSameAsNamedImport. +// If this is not the case, regenerate this file with moq. +var _ RequesterArgSameAsNamedImport = &RequesterArgSameAsNamedImportMoq{} + +// RequesterArgSameAsNamedImportMoq is a mock implementation of RequesterArgSameAsNamedImport. +// +// func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { +// +// // make and configure a mocked RequesterArgSameAsNamedImport +// mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImportMoq{ +// GetFunc: func(jsonMoqParam string) *json.RawMessage { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsNamedImport in code that requires RequesterArgSameAsNamedImport +// // and then make assertions. +// +// } +type RequesterArgSameAsNamedImportMoq struct { + // GetFunc mocks the Get method. + GetFunc func(jsonMoqParam string) *json.RawMessage + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // JsonMoqParam is the jsonMoqParam argument value. + JsonMoqParam string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsNamedImportMoq) Get(jsonMoqParam string) *json.RawMessage { + if mock.GetFunc == nil { + panic("RequesterArgSameAsNamedImportMoq.GetFunc: method is nil but RequesterArgSameAsNamedImport.Get was just called") + } + callInfo := struct { + JsonMoqParam string + }{ + JsonMoqParam: jsonMoqParam, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(jsonMoqParam) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsNamedImport.GetCalls()) +func (mock *RequesterArgSameAsNamedImportMoq) GetCalls() []struct { + JsonMoqParam string +} { + var calls []struct { + JsonMoqParam string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsNamedImportMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsNamedImportMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go new file mode 100644 index 00000000..6ee83028 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterArgSameAsPkgMoq does implement RequesterArgSameAsPkg. +// If this is not the case, regenerate this file with moq. +var _ RequesterArgSameAsPkg = &RequesterArgSameAsPkgMoq{} + +// RequesterArgSameAsPkgMoq is a mock implementation of RequesterArgSameAsPkg. +// +// func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { +// +// // make and configure a mocked RequesterArgSameAsPkg +// mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkgMoq{ +// GetFunc: func(test string) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArgSameAsPkg in code that requires RequesterArgSameAsPkg +// // and then make assertions. +// +// } +type RequesterArgSameAsPkgMoq struct { + // GetFunc mocks the Get method. + GetFunc func(test string) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Test is the test argument value. + Test string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArgSameAsPkgMoq) Get(test string) { + if mock.GetFunc == nil { + panic("RequesterArgSameAsPkgMoq.GetFunc: method is nil but RequesterArgSameAsPkg.Get was just called") + } + callInfo := struct { + Test string + }{ + Test: test, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + mock.GetFunc(test) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArgSameAsPkg.GetCalls()) +func (mock *RequesterArgSameAsPkgMoq) GetCalls() []struct { + Test string +} { + var calls []struct { + Test string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArgSameAsPkgMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArgSameAsPkgMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go new file mode 100644 index 00000000..9cf31280 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterArrayMoq does implement RequesterArray. +// If this is not the case, regenerate this file with moq. +var _ RequesterArray = &RequesterArrayMoq{} + +// RequesterArrayMoq is a mock implementation of RequesterArray. +// +// func TestSomethingThatUsesRequesterArray(t *testing.T) { +// +// // make and configure a mocked RequesterArray +// mockedRequesterArray := &RequesterArrayMoq{ +// GetFunc: func(path string) ([2]string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterArray in code that requires RequesterArray +// // and then make assertions. +// +// } +type RequesterArrayMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) ([2]string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterArrayMoq) Get(path string) ([2]string, error) { + if mock.GetFunc == nil { + panic("RequesterArrayMoq.GetFunc: method is nil but RequesterArray.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterArray.GetCalls()) +func (mock *RequesterArrayMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterArrayMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterArrayMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go new file mode 100644 index 00000000..f4d02b26 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go @@ -0,0 +1,94 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterElidedMoq does implement RequesterElided. +// If this is not the case, regenerate this file with moq. +var _ RequesterElided = &RequesterElidedMoq{} + +// RequesterElidedMoq is a mock implementation of RequesterElided. +// +// func TestSomethingThatUsesRequesterElided(t *testing.T) { +// +// // make and configure a mocked RequesterElided +// mockedRequesterElided := &RequesterElidedMoq{ +// GetFunc: func(path string, url string) error { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterElided in code that requires RequesterElided +// // and then make assertions. +// +// } +type RequesterElidedMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string, url string) error + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + // URL is the url argument value. + URL string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterElidedMoq) Get(path string, url string) error { + if mock.GetFunc == nil { + panic("RequesterElidedMoq.GetFunc: method is nil but RequesterElided.Get was just called") + } + callInfo := struct { + Path string + URL string + }{ + Path: path, + URL: url, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path, url) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterElided.GetCalls()) +func (mock *RequesterElidedMoq) GetCalls() []struct { + Path string + URL string +} { + var calls []struct { + Path string + URL string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterElidedMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterElidedMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go new file mode 100644 index 00000000..7181d378 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go @@ -0,0 +1,82 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "io" + "sync" +) + +// Ensure, that RequesterIfaceMoq does implement RequesterIface. +// If this is not the case, regenerate this file with moq. +var _ RequesterIface = &RequesterIfaceMoq{} + +// RequesterIfaceMoq is a mock implementation of RequesterIface. +// +// func TestSomethingThatUsesRequesterIface(t *testing.T) { +// +// // make and configure a mocked RequesterIface +// mockedRequesterIface := &RequesterIfaceMoq{ +// GetFunc: func() io.Reader { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterIface in code that requires RequesterIface +// // and then make assertions. +// +// } +type RequesterIfaceMoq struct { + // GetFunc mocks the Get method. + GetFunc func() io.Reader + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterIfaceMoq) Get() io.Reader { + if mock.GetFunc == nil { + panic("RequesterIfaceMoq.GetFunc: method is nil but RequesterIface.Get was just called") + } + callInfo := struct { + }{} + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc() +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterIface.GetCalls()) +func (mock *RequesterIfaceMoq) GetCalls() []struct { +} { + var calls []struct { + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterIfaceMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterIfaceMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go new file mode 100644 index 00000000..8e7a113d --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterMoq does implement Requester. +// If this is not the case, regenerate this file with moq. +var _ Requester = &RequesterMoq{} + +// RequesterMoq is a mock implementation of Requester. +// +// func TestSomethingThatUsesRequester(t *testing.T) { +// +// // make and configure a mocked Requester +// mockedRequester := &RequesterMoq{ +// GetFunc: func(path string) (string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequester in code that requires Requester +// // and then make assertions. +// +// } +type RequesterMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterMoq) Get(path string) (string, error) { + if mock.GetFunc == nil { + panic("RequesterMoq.GetFunc: method is nil but Requester.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequester.GetCalls()) +func (mock *RequesterMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go new file mode 100644 index 00000000..2dc1bd45 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go @@ -0,0 +1,89 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "net/http" + "sync" +) + +// Ensure, that RequesterNSMoq does implement RequesterNS. +// If this is not the case, regenerate this file with moq. +var _ RequesterNS = &RequesterNSMoq{} + +// RequesterNSMoq is a mock implementation of RequesterNS. +// +// func TestSomethingThatUsesRequesterNS(t *testing.T) { +// +// // make and configure a mocked RequesterNS +// mockedRequesterNS := &RequesterNSMoq{ +// GetFunc: func(path string) (http.Response, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterNS in code that requires RequesterNS +// // and then make assertions. +// +// } +type RequesterNSMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (http.Response, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterNSMoq) Get(path string) (http.Response, error) { + if mock.GetFunc == nil { + panic("RequesterNSMoq.GetFunc: method is nil but RequesterNS.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterNS.GetCalls()) +func (mock *RequesterNSMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterNSMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterNSMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go new file mode 100644 index 00000000..0b796d16 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterPtrMoq does implement RequesterPtr. +// If this is not the case, regenerate this file with moq. +var _ RequesterPtr = &RequesterPtrMoq{} + +// RequesterPtrMoq is a mock implementation of RequesterPtr. +// +// func TestSomethingThatUsesRequesterPtr(t *testing.T) { +// +// // make and configure a mocked RequesterPtr +// mockedRequesterPtr := &RequesterPtrMoq{ +// GetFunc: func(path string) (*string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterPtr in code that requires RequesterPtr +// // and then make assertions. +// +// } +type RequesterPtrMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (*string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterPtrMoq) Get(path string) (*string, error) { + if mock.GetFunc == nil { + panic("RequesterPtrMoq.GetFunc: method is nil but RequesterPtr.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterPtr.GetCalls()) +func (mock *RequesterPtrMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterPtrMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterPtrMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go new file mode 100644 index 00000000..27afd010 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go @@ -0,0 +1,143 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterReturnElidedMoq does implement RequesterReturnElided. +// If this is not the case, regenerate this file with moq. +var _ RequesterReturnElided = &RequesterReturnElidedMoq{} + +// RequesterReturnElidedMoq is a mock implementation of RequesterReturnElided. +// +// func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { +// +// // make and configure a mocked RequesterReturnElided +// mockedRequesterReturnElided := &RequesterReturnElidedMoq{ +// GetFunc: func(path string) (int, int, int, error) { +// panic("mock out the Get method") +// }, +// PutFunc: func(path string) (int, error) { +// panic("mock out the Put method") +// }, +// } +// +// // use mockedRequesterReturnElided in code that requires RequesterReturnElided +// // and then make assertions. +// +// } +type RequesterReturnElidedMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) (int, int, int, error) + + // PutFunc mocks the Put method. + PutFunc func(path string) (int, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + // Put holds details about calls to the Put method. + Put []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex + lockPut sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterReturnElidedMoq) Get(path string) (int, int, int, error) { + if mock.GetFunc == nil { + panic("RequesterReturnElidedMoq.GetFunc: method is nil but RequesterReturnElided.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterReturnElided.GetCalls()) +func (mock *RequesterReturnElidedMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterReturnElidedMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// Put calls PutFunc. +func (mock *RequesterReturnElidedMoq) Put(path string) (int, error) { + if mock.PutFunc == nil { + panic("RequesterReturnElidedMoq.PutFunc: method is nil but RequesterReturnElided.Put was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockPut.Lock() + mock.calls.Put = append(mock.calls.Put, callInfo) + mock.lockPut.Unlock() + return mock.PutFunc(path) +} + +// PutCalls gets all the calls that were made to Put. +// Check the length with: +// +// len(mockedRequesterReturnElided.PutCalls()) +func (mock *RequesterReturnElidedMoq) PutCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockPut.RLock() + calls = mock.calls.Put + mock.lockPut.RUnlock() + return calls +} + +// ResetPutCalls reset all the calls that were made to Put. +func (mock *RequesterReturnElidedMoq) ResetPutCalls() { + mock.lockPut.Lock() + mock.calls.Put = nil + mock.lockPut.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterReturnElidedMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockPut.Lock() + mock.calls.Put = nil + mock.lockPut.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go new file mode 100644 index 00000000..c33ad449 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that RequesterSliceMoq does implement RequesterSlice. +// If this is not the case, regenerate this file with moq. +var _ RequesterSlice = &RequesterSliceMoq{} + +// RequesterSliceMoq is a mock implementation of RequesterSlice. +// +// func TestSomethingThatUsesRequesterSlice(t *testing.T) { +// +// // make and configure a mocked RequesterSlice +// mockedRequesterSlice := &RequesterSliceMoq{ +// GetFunc: func(path string) ([]string, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedRequesterSlice in code that requires RequesterSlice +// // and then make assertions. +// +// } +type RequesterSliceMoq struct { + // GetFunc mocks the Get method. + GetFunc func(path string) ([]string, error) + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Path is the path argument value. + Path string + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterSliceMoq) Get(path string) ([]string, error) { + if mock.GetFunc == nil { + panic("RequesterSliceMoq.GetFunc: method is nil but RequesterSlice.Get was just called") + } + callInfo := struct { + Path string + }{ + Path: path, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(path) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterSlice.GetCalls()) +func (mock *RequesterSliceMoq) GetCalls() []struct { + Path string +} { + var calls []struct { + Path string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterSliceMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterSliceMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go new file mode 100644 index 00000000..94a4ae31 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go @@ -0,0 +1,266 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "io" + "sync" +) + +// Ensure, that RequesterVariadicMoq does implement RequesterVariadic. +// If this is not the case, regenerate this file with moq. +var _ RequesterVariadic = &RequesterVariadicMoq{} + +// RequesterVariadicMoq is a mock implementation of RequesterVariadic. +// +// func TestSomethingThatUsesRequesterVariadic(t *testing.T) { +// +// // make and configure a mocked RequesterVariadic +// mockedRequesterVariadic := &RequesterVariadicMoq{ +// GetFunc: func(values ...string) bool { +// panic("mock out the Get method") +// }, +// MultiWriteToFileFunc: func(filename string, w ...io.Writer) string { +// panic("mock out the MultiWriteToFile method") +// }, +// OneInterfaceFunc: func(a ...interface{}) bool { +// panic("mock out the OneInterface method") +// }, +// SprintfFunc: func(format string, a ...interface{}) string { +// panic("mock out the Sprintf method") +// }, +// } +// +// // use mockedRequesterVariadic in code that requires RequesterVariadic +// // and then make assertions. +// +// } +type RequesterVariadicMoq struct { + // GetFunc mocks the Get method. + GetFunc func(values ...string) bool + + // MultiWriteToFileFunc mocks the MultiWriteToFile method. + MultiWriteToFileFunc func(filename string, w ...io.Writer) string + + // OneInterfaceFunc mocks the OneInterface method. + OneInterfaceFunc func(a ...interface{}) bool + + // SprintfFunc mocks the Sprintf method. + SprintfFunc func(format string, a ...interface{}) string + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Values is the values argument value. + Values []string + } + // MultiWriteToFile holds details about calls to the MultiWriteToFile method. + MultiWriteToFile []struct { + // Filename is the filename argument value. + Filename string + // W is the w argument value. + W []io.Writer + } + // OneInterface holds details about calls to the OneInterface method. + OneInterface []struct { + // A is the a argument value. + A []interface{} + } + // Sprintf holds details about calls to the Sprintf method. + Sprintf []struct { + // Format is the format argument value. + Format string + // A is the a argument value. + A []interface{} + } + } + lockGet sync.RWMutex + lockMultiWriteToFile sync.RWMutex + lockOneInterface sync.RWMutex + lockSprintf sync.RWMutex +} + +// Get calls GetFunc. +func (mock *RequesterVariadicMoq) Get(values ...string) bool { + if mock.GetFunc == nil { + panic("RequesterVariadicMoq.GetFunc: method is nil but RequesterVariadic.Get was just called") + } + callInfo := struct { + Values []string + }{ + Values: values, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(values...) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedRequesterVariadic.GetCalls()) +func (mock *RequesterVariadicMoq) GetCalls() []struct { + Values []string +} { + var calls []struct { + Values []string + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} + +// ResetGetCalls reset all the calls that were made to Get. +func (mock *RequesterVariadicMoq) ResetGetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() +} + +// MultiWriteToFile calls MultiWriteToFileFunc. +func (mock *RequesterVariadicMoq) MultiWriteToFile(filename string, w ...io.Writer) string { + if mock.MultiWriteToFileFunc == nil { + panic("RequesterVariadicMoq.MultiWriteToFileFunc: method is nil but RequesterVariadic.MultiWriteToFile was just called") + } + callInfo := struct { + Filename string + W []io.Writer + }{ + Filename: filename, + W: w, + } + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = append(mock.calls.MultiWriteToFile, callInfo) + mock.lockMultiWriteToFile.Unlock() + return mock.MultiWriteToFileFunc(filename, w...) +} + +// MultiWriteToFileCalls gets all the calls that were made to MultiWriteToFile. +// Check the length with: +// +// len(mockedRequesterVariadic.MultiWriteToFileCalls()) +func (mock *RequesterVariadicMoq) MultiWriteToFileCalls() []struct { + Filename string + W []io.Writer +} { + var calls []struct { + Filename string + W []io.Writer + } + mock.lockMultiWriteToFile.RLock() + calls = mock.calls.MultiWriteToFile + mock.lockMultiWriteToFile.RUnlock() + return calls +} + +// ResetMultiWriteToFileCalls reset all the calls that were made to MultiWriteToFile. +func (mock *RequesterVariadicMoq) ResetMultiWriteToFileCalls() { + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = nil + mock.lockMultiWriteToFile.Unlock() +} + +// OneInterface calls OneInterfaceFunc. +func (mock *RequesterVariadicMoq) OneInterface(a ...interface{}) bool { + if mock.OneInterfaceFunc == nil { + panic("RequesterVariadicMoq.OneInterfaceFunc: method is nil but RequesterVariadic.OneInterface was just called") + } + callInfo := struct { + A []interface{} + }{ + A: a, + } + mock.lockOneInterface.Lock() + mock.calls.OneInterface = append(mock.calls.OneInterface, callInfo) + mock.lockOneInterface.Unlock() + return mock.OneInterfaceFunc(a...) +} + +// OneInterfaceCalls gets all the calls that were made to OneInterface. +// Check the length with: +// +// len(mockedRequesterVariadic.OneInterfaceCalls()) +func (mock *RequesterVariadicMoq) OneInterfaceCalls() []struct { + A []interface{} +} { + var calls []struct { + A []interface{} + } + mock.lockOneInterface.RLock() + calls = mock.calls.OneInterface + mock.lockOneInterface.RUnlock() + return calls +} + +// ResetOneInterfaceCalls reset all the calls that were made to OneInterface. +func (mock *RequesterVariadicMoq) ResetOneInterfaceCalls() { + mock.lockOneInterface.Lock() + mock.calls.OneInterface = nil + mock.lockOneInterface.Unlock() +} + +// Sprintf calls SprintfFunc. +func (mock *RequesterVariadicMoq) Sprintf(format string, a ...interface{}) string { + if mock.SprintfFunc == nil { + panic("RequesterVariadicMoq.SprintfFunc: method is nil but RequesterVariadic.Sprintf was just called") + } + callInfo := struct { + Format string + A []interface{} + }{ + Format: format, + A: a, + } + mock.lockSprintf.Lock() + mock.calls.Sprintf = append(mock.calls.Sprintf, callInfo) + mock.lockSprintf.Unlock() + return mock.SprintfFunc(format, a...) +} + +// SprintfCalls gets all the calls that were made to Sprintf. +// Check the length with: +// +// len(mockedRequesterVariadic.SprintfCalls()) +func (mock *RequesterVariadicMoq) SprintfCalls() []struct { + Format string + A []interface{} +} { + var calls []struct { + Format string + A []interface{} + } + mock.lockSprintf.RLock() + calls = mock.calls.Sprintf + mock.lockSprintf.RUnlock() + return calls +} + +// ResetSprintfCalls reset all the calls that were made to Sprintf. +func (mock *RequesterVariadicMoq) ResetSprintfCalls() { + mock.lockSprintf.Lock() + mock.calls.Sprintf = nil + mock.lockSprintf.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *RequesterVariadicMoq) ResetCalls() { + mock.lockGet.Lock() + mock.calls.Get = nil + mock.lockGet.Unlock() + + mock.lockMultiWriteToFile.Lock() + mock.calls.MultiWriteToFile = nil + mock.lockMultiWriteToFile.Unlock() + + mock.lockOneInterface.Lock() + mock.calls.OneInterface = nil + mock.lockOneInterface.Unlock() + + mock.lockSprintf.Lock() + mock.calls.Sprintf = nil + mock.lockSprintf.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go new file mode 100644 index 00000000..c845c33e --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go @@ -0,0 +1,81 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that SiblingMoq does implement Sibling. +// If this is not the case, regenerate this file with moq. +var _ Sibling = &SiblingMoq{} + +// SiblingMoq is a mock implementation of Sibling. +// +// func TestSomethingThatUsesSibling(t *testing.T) { +// +// // make and configure a mocked Sibling +// mockedSibling := &SiblingMoq{ +// DoSomethingFunc: func() { +// panic("mock out the DoSomething method") +// }, +// } +// +// // use mockedSibling in code that requires Sibling +// // and then make assertions. +// +// } +type SiblingMoq struct { + // DoSomethingFunc mocks the DoSomething method. + DoSomethingFunc func() + + // calls tracks calls to the methods. + calls struct { + // DoSomething holds details about calls to the DoSomething method. + DoSomething []struct { + } + } + lockDoSomething sync.RWMutex +} + +// DoSomething calls DoSomethingFunc. +func (mock *SiblingMoq) DoSomething() { + if mock.DoSomethingFunc == nil { + panic("SiblingMoq.DoSomethingFunc: method is nil but Sibling.DoSomething was just called") + } + callInfo := struct { + }{} + mock.lockDoSomething.Lock() + mock.calls.DoSomething = append(mock.calls.DoSomething, callInfo) + mock.lockDoSomething.Unlock() + mock.DoSomethingFunc() +} + +// DoSomethingCalls gets all the calls that were made to DoSomething. +// Check the length with: +// +// len(mockedSibling.DoSomethingCalls()) +func (mock *SiblingMoq) DoSomethingCalls() []struct { +} { + var calls []struct { + } + mock.lockDoSomething.RLock() + calls = mock.calls.DoSomething + mock.lockDoSomething.RUnlock() + return calls +} + +// ResetDoSomethingCalls reset all the calls that were made to DoSomething. +func (mock *SiblingMoq) ResetDoSomethingCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *SiblingMoq) ResetCalls() { + mock.lockDoSomething.Lock() + mock.calls.DoSomething = nil + mock.lockDoSomething.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go new file mode 100644 index 00000000..f42a0364 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go @@ -0,0 +1,112 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that StructWithTagMoq does implement StructWithTag. +// If this is not the case, regenerate this file with moq. +var _ StructWithTag = &StructWithTagMoq{} + +// StructWithTagMoq is a mock implementation of StructWithTag. +// +// func TestSomethingThatUsesStructWithTag(t *testing.T) { +// +// // make and configure a mocked StructWithTag +// mockedStructWithTag := &StructWithTagMoq{ +// MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { +// panic("mock out the MethodA method") +// }, +// } +// +// // use mockedStructWithTag in code that requires StructWithTag +// // and then make assertions. +// +// } +type StructWithTagMoq struct { + // MethodAFunc mocks the MethodA method. + MethodAFunc func(v *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + }) *struct { + FieldC int "json:\"field_c\"" + FieldD int "json:\"field_d\" xml:\"field_d\"" + } + + // calls tracks calls to the methods. + calls struct { + // MethodA holds details about calls to the MethodA method. + MethodA []struct { + // V is the v argument value. + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + } + } + lockMethodA sync.RWMutex +} + +// MethodA calls MethodAFunc. +func (mock *StructWithTagMoq) MethodA(v *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" +}) *struct { + FieldC int "json:\"field_c\"" + FieldD int "json:\"field_d\" xml:\"field_d\"" +} { + if mock.MethodAFunc == nil { + panic("StructWithTagMoq.MethodAFunc: method is nil but StructWithTag.MethodA was just called") + } + callInfo := struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + }{ + V: v, + } + mock.lockMethodA.Lock() + mock.calls.MethodA = append(mock.calls.MethodA, callInfo) + mock.lockMethodA.Unlock() + return mock.MethodAFunc(v) +} + +// MethodACalls gets all the calls that were made to MethodA. +// Check the length with: +// +// len(mockedStructWithTag.MethodACalls()) +func (mock *StructWithTagMoq) MethodACalls() []struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } +} { + var calls []struct { + V *struct { + FieldA int "json:\"field_a\"" + FieldB int "json:\"field_b\" xml:\"field_b\"" + } + } + mock.lockMethodA.RLock() + calls = mock.calls.MethodA + mock.lockMethodA.RUnlock() + return calls +} + +// ResetMethodACalls reset all the calls that were made to MethodA. +func (mock *StructWithTagMoq) ResetMethodACalls() { + mock.lockMethodA.Lock() + mock.calls.MethodA = nil + mock.lockMethodA.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *StructWithTagMoq) ResetCalls() { + mock.lockMethodA.Lock() + mock.calls.MethodA = nil + mock.lockMethodA.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go new file mode 100644 index 00000000..d9f03945 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go @@ -0,0 +1,90 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// Ensure, that UsesOtherPkgIfaceMoq does implement UsesOtherPkgIface. +// If this is not the case, regenerate this file with moq. +var _ UsesOtherPkgIface = &UsesOtherPkgIfaceMoq{} + +// UsesOtherPkgIfaceMoq is a mock implementation of UsesOtherPkgIface. +// +// func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { +// +// // make and configure a mocked UsesOtherPkgIface +// mockedUsesOtherPkgIface := &UsesOtherPkgIfaceMoq{ +// DoSomethingElseFunc: func(obj test.Sibling) { +// panic("mock out the DoSomethingElse method") +// }, +// } +// +// // use mockedUsesOtherPkgIface in code that requires UsesOtherPkgIface +// // and then make assertions. +// +// } +type UsesOtherPkgIfaceMoq struct { + // DoSomethingElseFunc mocks the DoSomethingElse method. + DoSomethingElseFunc func(obj test.Sibling) + + // calls tracks calls to the methods. + calls struct { + // DoSomethingElse holds details about calls to the DoSomethingElse method. + DoSomethingElse []struct { + // Obj is the obj argument value. + Obj test.Sibling + } + } + lockDoSomethingElse sync.RWMutex +} + +// DoSomethingElse calls DoSomethingElseFunc. +func (mock *UsesOtherPkgIfaceMoq) DoSomethingElse(obj test.Sibling) { + if mock.DoSomethingElseFunc == nil { + panic("UsesOtherPkgIfaceMoq.DoSomethingElseFunc: method is nil but UsesOtherPkgIface.DoSomethingElse was just called") + } + callInfo := struct { + Obj test.Sibling + }{ + Obj: obj, + } + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = append(mock.calls.DoSomethingElse, callInfo) + mock.lockDoSomethingElse.Unlock() + mock.DoSomethingElseFunc(obj) +} + +// DoSomethingElseCalls gets all the calls that were made to DoSomethingElse. +// Check the length with: +// +// len(mockedUsesOtherPkgIface.DoSomethingElseCalls()) +func (mock *UsesOtherPkgIfaceMoq) DoSomethingElseCalls() []struct { + Obj test.Sibling +} { + var calls []struct { + Obj test.Sibling + } + mock.lockDoSomethingElse.RLock() + calls = mock.calls.DoSomethingElse + mock.lockDoSomethingElse.RUnlock() + return calls +} + +// ResetDoSomethingElseCalls reset all the calls that were made to DoSomethingElse. +func (mock *UsesOtherPkgIfaceMoq) ResetDoSomethingElseCalls() { + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = nil + mock.lockDoSomethingElse.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *UsesOtherPkgIfaceMoq) ResetCalls() { + mock.lockDoSomethingElse.Lock() + mock.calls.DoSomethingElse = nil + mock.lockDoSomethingElse.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go new file mode 100644 index 00000000..5167dde5 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go @@ -0,0 +1,94 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that VariadicMoq does implement Variadic. +// If this is not the case, regenerate this file with moq. +var _ Variadic = &VariadicMoq{} + +// VariadicMoq is a mock implementation of Variadic. +// +// func TestSomethingThatUsesVariadic(t *testing.T) { +// +// // make and configure a mocked Variadic +// mockedVariadic := &VariadicMoq{ +// VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { +// panic("mock out the VariadicFunction method") +// }, +// } +// +// // use mockedVariadic in code that requires Variadic +// // and then make assertions. +// +// } +type VariadicMoq struct { + // VariadicFunctionFunc mocks the VariadicFunction method. + VariadicFunctionFunc func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error + + // calls tracks calls to the methods. + calls struct { + // VariadicFunction holds details about calls to the VariadicFunction method. + VariadicFunction []struct { + // Str is the str argument value. + Str string + // VFunc is the vFunc argument value. + VFunc func(args1 string, args2 ...interface{}) interface{} + } + } + lockVariadicFunction sync.RWMutex +} + +// VariadicFunction calls VariadicFunctionFunc. +func (mock *VariadicMoq) VariadicFunction(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { + if mock.VariadicFunctionFunc == nil { + panic("VariadicMoq.VariadicFunctionFunc: method is nil but Variadic.VariadicFunction was just called") + } + callInfo := struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} + }{ + Str: str, + VFunc: vFunc, + } + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = append(mock.calls.VariadicFunction, callInfo) + mock.lockVariadicFunction.Unlock() + return mock.VariadicFunctionFunc(str, vFunc) +} + +// VariadicFunctionCalls gets all the calls that were made to VariadicFunction. +// Check the length with: +// +// len(mockedVariadic.VariadicFunctionCalls()) +func (mock *VariadicMoq) VariadicFunctionCalls() []struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} +} { + var calls []struct { + Str string + VFunc func(args1 string, args2 ...interface{}) interface{} + } + mock.lockVariadicFunction.RLock() + calls = mock.calls.VariadicFunction + mock.lockVariadicFunction.RUnlock() + return calls +} + +// ResetVariadicFunctionCalls reset all the calls that were made to VariadicFunction. +func (mock *VariadicMoq) ResetVariadicFunctionCalls() { + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = nil + mock.lockVariadicFunction.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *VariadicMoq) ResetCalls() { + mock.lockVariadicFunction.Lock() + mock.calls.VariadicFunction = nil + mock.lockVariadicFunction.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go new file mode 100644 index 00000000..5818d8a8 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go @@ -0,0 +1,94 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that VariadicNoReturnInterfaceMoq does implement VariadicNoReturnInterface. +// If this is not the case, regenerate this file with moq. +var _ VariadicNoReturnInterface = &VariadicNoReturnInterfaceMoq{} + +// VariadicNoReturnInterfaceMoq is a mock implementation of VariadicNoReturnInterface. +// +// func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { +// +// // make and configure a mocked VariadicNoReturnInterface +// mockedVariadicNoReturnInterface := &VariadicNoReturnInterfaceMoq{ +// VariadicNoReturnFunc: func(j int, is ...interface{}) { +// panic("mock out the VariadicNoReturn method") +// }, +// } +// +// // use mockedVariadicNoReturnInterface in code that requires VariadicNoReturnInterface +// // and then make assertions. +// +// } +type VariadicNoReturnInterfaceMoq struct { + // VariadicNoReturnFunc mocks the VariadicNoReturn method. + VariadicNoReturnFunc func(j int, is ...interface{}) + + // calls tracks calls to the methods. + calls struct { + // VariadicNoReturn holds details about calls to the VariadicNoReturn method. + VariadicNoReturn []struct { + // J is the j argument value. + J int + // Is is the is argument value. + Is []interface{} + } + } + lockVariadicNoReturn sync.RWMutex +} + +// VariadicNoReturn calls VariadicNoReturnFunc. +func (mock *VariadicNoReturnInterfaceMoq) VariadicNoReturn(j int, is ...interface{}) { + if mock.VariadicNoReturnFunc == nil { + panic("VariadicNoReturnInterfaceMoq.VariadicNoReturnFunc: method is nil but VariadicNoReturnInterface.VariadicNoReturn was just called") + } + callInfo := struct { + J int + Is []interface{} + }{ + J: j, + Is: is, + } + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = append(mock.calls.VariadicNoReturn, callInfo) + mock.lockVariadicNoReturn.Unlock() + mock.VariadicNoReturnFunc(j, is...) +} + +// VariadicNoReturnCalls gets all the calls that were made to VariadicNoReturn. +// Check the length with: +// +// len(mockedVariadicNoReturnInterface.VariadicNoReturnCalls()) +func (mock *VariadicNoReturnInterfaceMoq) VariadicNoReturnCalls() []struct { + J int + Is []interface{} +} { + var calls []struct { + J int + Is []interface{} + } + mock.lockVariadicNoReturn.RLock() + calls = mock.calls.VariadicNoReturn + mock.lockVariadicNoReturn.RUnlock() + return calls +} + +// ResetVariadicNoReturnCalls reset all the calls that were made to VariadicNoReturn. +func (mock *VariadicNoReturnInterfaceMoq) ResetVariadicNoReturnCalls() { + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = nil + mock.lockVariadicNoReturn.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *VariadicNoReturnInterfaceMoq) ResetCalls() { + mock.lockVariadicNoReturn.Lock() + mock.calls.VariadicNoReturn = nil + mock.lockVariadicNoReturn.Unlock() +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go new file mode 100644 index 00000000..b6bee662 --- /dev/null +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go @@ -0,0 +1,88 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package test + +import ( + "sync" +) + +// Ensure, that VariadicReturnFuncMoq does implement VariadicReturnFunc. +// If this is not the case, regenerate this file with moq. +var _ VariadicReturnFunc = &VariadicReturnFuncMoq{} + +// VariadicReturnFuncMoq is a mock implementation of VariadicReturnFunc. +// +// func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { +// +// // make and configure a mocked VariadicReturnFunc +// mockedVariadicReturnFunc := &VariadicReturnFuncMoq{ +// SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { +// panic("mock out the SampleMethod method") +// }, +// } +// +// // use mockedVariadicReturnFunc in code that requires VariadicReturnFunc +// // and then make assertions. +// +// } +type VariadicReturnFuncMoq struct { + // SampleMethodFunc mocks the SampleMethod method. + SampleMethodFunc func(str string) func(str string, arr []int, a ...interface{}) + + // calls tracks calls to the methods. + calls struct { + // SampleMethod holds details about calls to the SampleMethod method. + SampleMethod []struct { + // Str is the str argument value. + Str string + } + } + lockSampleMethod sync.RWMutex +} + +// SampleMethod calls SampleMethodFunc. +func (mock *VariadicReturnFuncMoq) SampleMethod(str string) func(str string, arr []int, a ...interface{}) { + if mock.SampleMethodFunc == nil { + panic("VariadicReturnFuncMoq.SampleMethodFunc: method is nil but VariadicReturnFunc.SampleMethod was just called") + } + callInfo := struct { + Str string + }{ + Str: str, + } + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = append(mock.calls.SampleMethod, callInfo) + mock.lockSampleMethod.Unlock() + return mock.SampleMethodFunc(str) +} + +// SampleMethodCalls gets all the calls that were made to SampleMethod. +// Check the length with: +// +// len(mockedVariadicReturnFunc.SampleMethodCalls()) +func (mock *VariadicReturnFuncMoq) SampleMethodCalls() []struct { + Str string +} { + var calls []struct { + Str string + } + mock.lockSampleMethod.RLock() + calls = mock.calls.SampleMethod + mock.lockSampleMethod.RUnlock() + return calls +} + +// ResetSampleMethodCalls reset all the calls that were made to SampleMethod. +func (mock *VariadicReturnFuncMoq) ResetSampleMethodCalls() { + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = nil + mock.lockSampleMethod.Unlock() +} + +// ResetCalls reset all the calls that were made to all mocked methods. +func (mock *VariadicReturnFuncMoq) ResetCalls() { + mock.lockSampleMethod.Lock() + mock.calls.SampleMethod = nil + mock.lockSampleMethod.Unlock() +} diff --git a/pkg/fixtures/inpackage/foo_moq.go b/pkg/fixtures/inpackage/foo_moq.go new file mode 100644 index 00000000..c2091385 --- /dev/null +++ b/pkg/fixtures/inpackage/foo_moq.go @@ -0,0 +1,74 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery + +package inpackage + +import ( + "sync" +) + +// Ensure, that FooMoq does implement Foo. +// If this is not the case, regenerate this file with moq. +var _ Foo = &FooMoq{} + +// FooMoq is a mock implementation of Foo. +// +// func TestSomethingThatUsesFoo(t *testing.T) { +// +// // make and configure a mocked Foo +// mockedFoo := &FooMoq{ +// GetFunc: func(key ArgType) ReturnType { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedFoo in code that requires Foo +// // and then make assertions. +// +// } +type FooMoq struct { + // GetFunc mocks the Get method. + GetFunc func(key ArgType) ReturnType + + // calls tracks calls to the methods. + calls struct { + // Get holds details about calls to the Get method. + Get []struct { + // Key is the key argument value. + Key ArgType + } + } + lockGet sync.RWMutex +} + +// Get calls GetFunc. +func (mock *FooMoq) Get(key ArgType) ReturnType { + if mock.GetFunc == nil { + panic("FooMoq.GetFunc: method is nil but Foo.Get was just called") + } + callInfo := struct { + Key ArgType + }{ + Key: key, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(key) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedFoo.GetCalls()) +func (mock *FooMoq) GetCalls() []struct { + Key ArgType +} { + var calls []struct { + Key ArgType + } + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/pkg/fixtures/inpackage/foo_test.go b/pkg/fixtures/inpackage/foo_test.go new file mode 100644 index 00000000..3cc33777 --- /dev/null +++ b/pkg/fixtures/inpackage/foo_test.go @@ -0,0 +1,16 @@ +package inpackage + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMoq(t *testing.T) { + mock := FooMoq{ + GetFunc: func(key ArgType) ReturnType { + return ReturnType(key + "suffix") + }, + } + assert.Equal(t, mock.Get("foo"), ReturnType("foosuffix")) +} diff --git a/pkg/fixtures/recursive_generation/Foo_mock.go b/pkg/fixtures/recursive_generation/Foo_mock.go new file mode 100644 index 00000000..1374b9fa --- /dev/null +++ b/pkg/fixtures/recursive_generation/Foo_mock.go @@ -0,0 +1,77 @@ +// Code generated by mockery. DO NOT EDIT. + +package recursive_generation + +import mock "github.com/stretchr/testify/mock" + +// MockFoo is an autogenerated mock type for the Foo type +type MockFoo struct { + mock.Mock +} + +type MockFoo_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFoo) EXPECT() *MockFoo_Expecter { + return &MockFoo_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: +func (_m *MockFoo) Get() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockFoo_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { + return &MockFoo_Get_Call{Call: _e.mock.On("Get")} +} + +func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockFoo(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFoo { + mock := &MockFoo{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go new file mode 100644 index 00000000..50697c1d --- /dev/null +++ b/pkg/fixtures/recursive_generation/subpkg1/Foo_mock.go @@ -0,0 +1,77 @@ +// Code generated by mockery. DO NOT EDIT. + +package subpkg1 + +import mock "github.com/stretchr/testify/mock" + +// MockFoo is an autogenerated mock type for the Foo type +type MockFoo struct { + mock.Mock +} + +type MockFoo_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFoo) EXPECT() *MockFoo_Expecter { + return &MockFoo_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: +func (_m *MockFoo) Get() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockFoo_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { + return &MockFoo_Get_Call{Call: _e.mock.On("Get")} +} + +func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockFoo(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFoo { + mock := &MockFoo{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go new file mode 100644 index 00000000..fe92d118 --- /dev/null +++ b/pkg/fixtures/recursive_generation/subpkg2/Foo_mock.go @@ -0,0 +1,77 @@ +// Code generated by mockery. DO NOT EDIT. + +package subpkg2 + +import mock "github.com/stretchr/testify/mock" + +// MockFoo is an autogenerated mock type for the Foo type +type MockFoo struct { + mock.Mock +} + +type MockFoo_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFoo) EXPECT() *MockFoo_Expecter { + return &MockFoo_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: +func (_m *MockFoo) Get() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockFoo_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { + return &MockFoo_Get_Call{Call: _e.mock.On("Get")} +} + +func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockFoo(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFoo { + mock := &MockFoo{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go b/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go new file mode 100644 index 00000000..9648bcfd --- /dev/null +++ b/pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go @@ -0,0 +1,77 @@ +// Code generated by mockery. DO NOT EDIT. + +package subpkg_with_only_autogenerated_files + +import mock "github.com/stretchr/testify/mock" + +// MockFoo is an autogenerated mock type for the Foo type +type MockFoo struct { + mock.Mock +} + +type MockFoo_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFoo) EXPECT() *MockFoo_Expecter { + return &MockFoo_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: +func (_m *MockFoo) Get() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockFoo_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockFoo_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +func (_e *MockFoo_Expecter) Get() *MockFoo_Get_Call { + return &MockFoo_Get_Call{Call: _e.mock.On("Get")} +} + +func (_c *MockFoo_Get_Call) Run(run func()) *MockFoo_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFoo_Get_Call) Return(_a0 string) *MockFoo_Get_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFoo_Get_Call) RunAndReturn(run func() string) *MockFoo_Get_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFoo creates a new instance of MockFoo. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockFoo(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFoo { + mock := &MockFoo{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/generator/template_generator.go b/pkg/generator/template_generator.go index bb180093..51144622 100644 --- a/pkg/generator/template_generator.go +++ b/pkg/generator/template_generator.go @@ -26,8 +26,8 @@ type TemplateGenerator struct { registry *registry.Registry } -func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConfig, outPkg string) (*TemplateGenerator, error) { - reg, err := registry.New(srcPkg, outPkg) +func NewTemplateGenerator(srcPkg *packages.Package, config TemplateGeneratorConfig, outPkgPath string) (*TemplateGenerator, error) { + reg, err := registry.New(srcPkg, outPkgPath) if err != nil { return nil, fmt.Errorf("creating new registry: %w", err) } diff --git a/pkg/outputter.go b/pkg/outputter.go index 5d2a36e7..e2829a13 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -334,13 +334,27 @@ func (o *Outputter) Generate(ctx context.Context, iface *Interface) error { } continue } - logging.WarnAlpha(ifaceCtx, "usage of mock styles other than mockery is currently in an alpha state.", nil) + logging.WarnAlpha(ifaceCtx, "usage of mock styles other than mockery is currently in an alpha state.", nil) ifaceLog.Debug().Msg("generating templated mock") config := generator.TemplateGeneratorConfig{ Style: interfaceConfig.Style, } - generator, err := generator.NewTemplateGenerator(iface.PackagesPackage, config, interfaceConfig.Outpkg) + + // The registry needs to know what the mock's package path is, to determine + // whether or not to import the originating package. There's not a super good + // way to do this automatically. The automatic solution would be to search for + // a go.mod file up to root, then append the mock's relative path with the declared + // module name. Maybe we will do that in the future, but for now we will rely on + // the user having to configure this. Another solution: check if interfaceConfig.Dir + // equals the original interface path? + var outPkgPath string + if interfaceConfig.InPackage { + outPkgPath = iface.Pkg.Path() + } else { + outPkgPath = interfaceConfig.Dir + } + generator, err := generator.NewTemplateGenerator(iface.PackagesPackage, config, outPkgPath) if err != nil { return fmt.Errorf("creating template generator: %w", err) } diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 1e96566b..76d615d7 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -18,7 +18,7 @@ import ( // imports and ensures there are no conflicts in the imported package // qualifiers. type Registry struct { - dstPkg string + dstPkgPath string srcPkgName string srcPkgTypes *types.Package aliases map[string]string @@ -27,9 +27,9 @@ type Registry struct { // New loads the source package info and returns a new instance of // Registry. -func New(srcPkg *packages.Package, dstPkg string) (*Registry, error) { +func New(srcPkg *packages.Package, dstPkgPath string) (*Registry, error) { return &Registry{ - dstPkg: dstPkg, + dstPkgPath: dstPkgPath, srcPkgName: srcPkg.Name, srcPkgTypes: srcPkg.Types, aliases: parseImportsAliases(srcPkg.Syntax), @@ -82,8 +82,8 @@ func (r *Registry) MethodScope() *MethodScope { func (r *Registry) AddImport(ctx context.Context, pkg *types.Package) *Package { log := zerolog.Ctx(ctx) path := pkg.Path() - log.Debug().Str("method", "AddImport").Str("src-pkg-path", path).Str("dst-pkg", r.dstPkg).Msg("adding import") - if path == r.dstPkg { + log.Debug().Str("method", "AddImport").Str("src-pkg-path", path).Str("dst-pkg-path", r.dstPkgPath).Msg("adding import") + if path == r.dstPkgPath { return nil } From a9aac882060e8fb86607cd887c84b48ba8ecb72f Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 14:28:30 -0600 Subject: [PATCH 45/50] Fix issue with registry not importing original package --- .mockery-moq.yaml | 2 +- cmd/mockery.go | 4 ++-- pkg/config/config.go | 9 ++++++++- pkg/config/config_test.go | 2 +- pkg/generator/template_generator.go | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.mockery-moq.yaml b/.mockery-moq.yaml index 51bf00c9..f62f17ac 100644 --- a/.mockery-moq.yaml +++ b/.mockery-moq.yaml @@ -14,10 +14,10 @@ packages: with-resets: true skip-ensure: false stub-impl: false + inpackage: false github.com/vektra/mockery/v2/pkg/fixtures/inpackage: config: dir: "{{.InterfaceDir}}" all: True outpkg: "{{.PackageName}}" inpackage: true - \ No newline at end of file diff --git a/cmd/mockery.go b/cmd/mockery.go index ae90e8c4..489f0696 100644 --- a/cmd/mockery.go +++ b/cmd/mockery.go @@ -234,7 +234,7 @@ func (r *RootApp) Run() error { if err != nil { return fmt.Errorf("failed to get package from config: %w", err) } - parser := pkg.NewParser(buildTags, pkg.ParserSkipFunctions(true)) + parser := pkg.NewParser(buildTags, pkg.ParserSkipFunctions(false)) if err := parser.ParsePackages(ctx, configuredPackages); err != nil { log.Error().Err(err).Msg("unable to parse packages") @@ -255,7 +255,7 @@ func (r *RootApp) Run() error { ifaceCtx := ifaceLog.WithContext(ctx) - shouldGenerate, err := r.Config.ShouldGenerateInterface(ifaceCtx, iface.QualifiedName, iface.Name) + shouldGenerate, err := r.Config.ShouldGenerateInterface(ifaceCtx, iface.QualifiedName, iface.Name, iface.IsFunction) if err != nil { return err } diff --git a/pkg/config/config.go b/pkg/config/config.go index 3e394e06..b088ae70 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -293,12 +293,19 @@ func (c *Config) ExcludePath(path string) bool { return false } -func (c *Config) ShouldGenerateInterface(ctx context.Context, packageName, interfaceName string) (bool, error) { +func (c *Config) ShouldGenerateInterface(ctx context.Context, packageName, interfaceName string, isFunction bool) (bool, error) { pkgConfig, err := c.GetPackageConfig(ctx, packageName) if err != nil { return false, fmt.Errorf("getting package config: %w", err) } + ifaceCfg, err := c.GetInterfaceConfig(ctx, packageName, interfaceName) + if err != nil { + return false, err + } + if ifaceCfg[0].Style != "mockery" && isFunction { + return false, nil + } log := zerolog.Ctx(ctx) if pkgConfig.All { if pkgConfig.IncludeRegex != "" { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 11eb4b8f..27ce9cf8 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -818,7 +818,7 @@ func TestConfig_ShouldGenerateInterface(t *testing.T) { t.Run(tt.name, func(t *testing.T) { tt.c.Config = writeConfigFile(t, tt.c) - got, err := tt.c.ShouldGenerateInterface(context.Background(), "some_package", "SomeInterface") + got, err := tt.c.ShouldGenerateInterface(context.Background(), "some_package", "SomeInterface", false) if (err != nil) != tt.wantErr { t.Errorf("Config.ShouldGenerateInterface() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/pkg/generator/template_generator.go b/pkg/generator/template_generator.go index 51144622..05621303 100644 --- a/pkg/generator/template_generator.go +++ b/pkg/generator/template_generator.go @@ -150,7 +150,7 @@ func (g *TemplateGenerator) Generate(ctx context.Context, ifaceName string, ifac g.registry.AddImport(ctx, types.NewPackage("sync", "sync")) } - if g.registry.SrcPkgName() != ifaceConfig.Outpkg { + if !ifaceConfig.InPackage { data.SrcPkgQualifier = g.registry.SrcPkgName() + "." skipEnsure, ok := ifaceConfig.TemplateMap["skip-ensure"] if !ok || !skipEnsure.(bool) { From f57f7b1888291ff3f7c0b15a3e0abdf8934fefd6 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 14:28:46 -0600 Subject: [PATCH 46/50] update moqs --- .../mockery/v2/pkg/fixtures/SendFunc.go | 93 +++++++++++++++++++ .../vektra/mockery/v2/pkg/fixtures/a_moq.go | 10 +- .../v2/pkg/fixtures/async_producer_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/blank_moq.go | 12 ++- .../v2/pkg/fixtures/consul_lock_moq.go | 12 ++- .../v2/pkg/fixtures/embedded_get_moq.go | 11 ++- .../mockery/v2/pkg/fixtures/example_moq.go | 11 ++- .../mockery/v2/pkg/fixtures/expecter_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/fooer_moq.go | 12 ++- .../pkg/fixtures/func_args_collision_moq.go | 12 ++- .../v2/pkg/fixtures/get_generic_moq.go | 11 ++- .../mockery/v2/pkg/fixtures/get_int_moq.go | 12 ++- .../has_conflicting_nested_imports_moq.go | 11 ++- .../fixtures/imports_same_as_package_moq.go | 10 +- .../v2/pkg/fixtures/key_manager_moq.go | 10 +- .../mockery/v2/pkg/fixtures/map_func_moq.go | 12 ++- .../v2/pkg/fixtures/map_to_interface_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/my_reader_moq.go | 12 ++- .../fixtures/panic_on_no_return_value_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/requester2_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/requester3_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/requester4_moq.go | 12 ++- .../requester_arg_same_as_import_moq.go | 12 ++- .../requester_arg_same_as_named_import_moq.go | 12 ++- .../fixtures/requester_arg_same_as_pkg_moq.go | 12 ++- .../v2/pkg/fixtures/requester_array_moq.go | 12 ++- .../v2/pkg/fixtures/requester_elided_moq.go | 12 ++- .../v2/pkg/fixtures/requester_iface_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/requester_moq.go | 12 ++- .../v2/pkg/fixtures/requester_ns_moq.go | 12 ++- .../v2/pkg/fixtures/requester_ptr_moq.go | 12 ++- .../fixtures/requester_return_elided_moq.go | 12 ++- .../v2/pkg/fixtures/requester_slice_moq.go | 12 ++- .../v2/pkg/fixtures/requester_variadic_moq.go | 12 ++- .../mockery/v2/pkg/fixtures/sibling_moq.go | 12 ++- .../v2/pkg/fixtures/struct_with_tag_moq.go | 12 ++- .../pkg/fixtures/uses_other_pkg_iface_moq.go | 10 +- .../mockery/v2/pkg/fixtures/variadic_moq.go | 12 ++- .../variadic_no_return_interface_moq.go | 12 ++- .../pkg/fixtures/variadic_return_func_moq.go | 12 ++- 40 files changed, 354 insertions(+), 195 deletions(-) create mode 100644 mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go diff --git a/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go new file mode 100644 index 00000000..740fe462 --- /dev/null +++ b/mocks/github.com/vektra/mockery/v2/pkg/fixtures/SendFunc.go @@ -0,0 +1,93 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// SendFunc is an autogenerated mock type for the SendFunc type +type SendFunc struct { + mock.Mock +} + +type SendFunc_Expecter struct { + mock *mock.Mock +} + +func (_m *SendFunc) EXPECT() *SendFunc_Expecter { + return &SendFunc_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: ctx, data +func (_m *SendFunc) Execute(ctx context.Context, data string) (int, error) { + ret := _m.Called(ctx, data) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (int, error)); ok { + return rf(ctx, data) + } + if rf, ok := ret.Get(0).(func(context.Context, string) int); ok { + r0 = rf(ctx, data) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SendFunc_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type SendFunc_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - ctx context.Context +// - data string +func (_e *SendFunc_Expecter) Execute(ctx interface{}, data interface{}) *SendFunc_Execute_Call { + return &SendFunc_Execute_Call{Call: _e.mock.On("Execute", ctx, data)} +} + +func (_c *SendFunc_Execute_Call) Run(run func(ctx context.Context, data string)) *SendFunc_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *SendFunc_Execute_Call) Return(_a0 int, _a1 error) *SendFunc_Execute_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SendFunc_Execute_Call) RunAndReturn(run func(context.Context, string) (int, error)) *SendFunc_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewSendFunc creates a new instance of SendFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSendFunc(t interface { + mock.TestingT + Cleanup(func()) +}) *SendFunc { + mock := &SendFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go index 850de8f6..0c65db54 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/a_moq.go @@ -9,22 +9,22 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that AMoq does implement A. +// Ensure, that AMoq does implement test.A. // If this is not the case, regenerate this file with moq. -var _ A = &AMoq{} +var _ test.A = &AMoq{} -// AMoq is a mock implementation of A. +// AMoq is a mock implementation of test.A. // // func TestSomethingThatUsesA(t *testing.T) { // -// // make and configure a mocked A +// // make and configure a mocked test.A // mockedA := &AMoq{ // CallFunc: func() (test.B, error) { // panic("mock out the Call method") // }, // } // -// // use mockedA in code that requires A +// // use mockedA in code that requires test.A // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go index 4e8cf652..e26567f4 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/async_producer_moq.go @@ -5,17 +5,19 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that AsyncProducerMoq does implement AsyncProducer. +// Ensure, that AsyncProducerMoq does implement test.AsyncProducer. // If this is not the case, regenerate this file with moq. -var _ AsyncProducer = &AsyncProducerMoq{} +var _ test.AsyncProducer = &AsyncProducerMoq{} -// AsyncProducerMoq is a mock implementation of AsyncProducer. +// AsyncProducerMoq is a mock implementation of test.AsyncProducer. // // func TestSomethingThatUsesAsyncProducer(t *testing.T) { // -// // make and configure a mocked AsyncProducer +// // make and configure a mocked test.AsyncProducer // mockedAsyncProducer := &AsyncProducerMoq{ // InputFunc: func() chan<- bool { // panic("mock out the Input method") @@ -28,7 +30,7 @@ var _ AsyncProducer = &AsyncProducerMoq{} // }, // } // -// // use mockedAsyncProducer in code that requires AsyncProducer +// // use mockedAsyncProducer in code that requires test.AsyncProducer // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go index 8706bd56..babe7986 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/blank_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that BlankMoq does implement Blank. +// Ensure, that BlankMoq does implement test.Blank. // If this is not the case, regenerate this file with moq. -var _ Blank = &BlankMoq{} +var _ test.Blank = &BlankMoq{} -// BlankMoq is a mock implementation of Blank. +// BlankMoq is a mock implementation of test.Blank. // // func TestSomethingThatUsesBlank(t *testing.T) { // -// // make and configure a mocked Blank +// // make and configure a mocked test.Blank // mockedBlank := &BlankMoq{ // CreateFunc: func(x interface{}) error { // panic("mock out the Create method") // }, // } // -// // use mockedBlank in code that requires Blank +// // use mockedBlank in code that requires test.Blank // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go index cb171f7f..eda9ae2c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/consul_lock_moq.go @@ -5,17 +5,19 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that ConsulLockMoq does implement ConsulLock. +// Ensure, that ConsulLockMoq does implement test.ConsulLock. // If this is not the case, regenerate this file with moq. -var _ ConsulLock = &ConsulLockMoq{} +var _ test.ConsulLock = &ConsulLockMoq{} -// ConsulLockMoq is a mock implementation of ConsulLock. +// ConsulLockMoq is a mock implementation of test.ConsulLock. // // func TestSomethingThatUsesConsulLock(t *testing.T) { // -// // make and configure a mocked ConsulLock +// // make and configure a mocked test.ConsulLock // mockedConsulLock := &ConsulLockMoq{ // LockFunc: func(valCh <-chan struct{}) (<-chan struct{}, error) { // panic("mock out the Lock method") @@ -25,7 +27,7 @@ var _ ConsulLock = &ConsulLockMoq{} // }, // } // -// // use mockedConsulLock in code that requires ConsulLock +// // use mockedConsulLock in code that requires test.ConsulLock // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go index ad3c70cb..d987aae8 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/embedded_get_moq.go @@ -6,25 +6,26 @@ package test import ( "sync" + test "github.com/vektra/mockery/v2/pkg/fixtures" "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// Ensure, that EmbeddedGetMoq does implement EmbeddedGet. +// Ensure, that EmbeddedGetMoq does implement test.EmbeddedGet. // If this is not the case, regenerate this file with moq. -var _ EmbeddedGet[int] = &EmbeddedGetMoq[int]{} +var _ test.EmbeddedGet[int] = &EmbeddedGetMoq[int]{} -// EmbeddedGetMoq is a mock implementation of EmbeddedGet. +// EmbeddedGetMoq is a mock implementation of test.EmbeddedGet. // // func TestSomethingThatUsesEmbeddedGet(t *testing.T) { // -// // make and configure a mocked EmbeddedGet +// // make and configure a mocked test.EmbeddedGet // mockedEmbeddedGet := &EmbeddedGetMoq{ // GetFunc: func() T { // panic("mock out the Get method") // }, // } // -// // use mockedEmbeddedGet in code that requires EmbeddedGet +// // use mockedEmbeddedGet in code that requires test.EmbeddedGet // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go index 421cdd63..77112efb 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/example_moq.go @@ -7,18 +7,19 @@ import ( "net/http" "sync" + test "github.com/vektra/mockery/v2/pkg/fixtures" my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// Ensure, that ExampleMoq does implement Example. +// Ensure, that ExampleMoq does implement test.Example. // If this is not the case, regenerate this file with moq. -var _ Example = &ExampleMoq{} +var _ test.Example = &ExampleMoq{} -// ExampleMoq is a mock implementation of Example. +// ExampleMoq is a mock implementation of test.Example. // // func TestSomethingThatUsesExample(t *testing.T) { // -// // make and configure a mocked Example +// // make and configure a mocked test.Example // mockedExample := &ExampleMoq{ // AFunc: func() http.Flusher { // panic("mock out the A method") @@ -28,7 +29,7 @@ var _ Example = &ExampleMoq{} // }, // } // -// // use mockedExample in code that requires Example +// // use mockedExample in code that requires test.Example // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go index f5532bdc..7e2c68a0 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/expecter_moq.go @@ -5,17 +5,19 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that ExpecterMoq does implement Expecter. +// Ensure, that ExpecterMoq does implement test.Expecter. // If this is not the case, regenerate this file with moq. -var _ Expecter = &ExpecterMoq{} +var _ test.Expecter = &ExpecterMoq{} -// ExpecterMoq is a mock implementation of Expecter. +// ExpecterMoq is a mock implementation of test.Expecter. // // func TestSomethingThatUsesExpecter(t *testing.T) { // -// // make and configure a mocked Expecter +// // make and configure a mocked test.Expecter // mockedExpecter := &ExpecterMoq{ // ManyArgsReturnsFunc: func(str string, i int) ([]string, error) { // panic("mock out the ManyArgsReturns method") @@ -34,7 +36,7 @@ var _ Expecter = &ExpecterMoq{} // }, // } // -// // use mockedExpecter in code that requires Expecter +// // use mockedExpecter in code that requires test.Expecter // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go index 0e5ffc2a..3ac56c12 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/fooer_moq.go @@ -5,17 +5,19 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that FooerMoq does implement Fooer. +// Ensure, that FooerMoq does implement test.Fooer. // If this is not the case, regenerate this file with moq. -var _ Fooer = &FooerMoq{} +var _ test.Fooer = &FooerMoq{} -// FooerMoq is a mock implementation of Fooer. +// FooerMoq is a mock implementation of test.Fooer. // // func TestSomethingThatUsesFooer(t *testing.T) { // -// // make and configure a mocked Fooer +// // make and configure a mocked test.Fooer // mockedFooer := &FooerMoq{ // BarFunc: func(f func([]int)) { // panic("mock out the Bar method") @@ -28,7 +30,7 @@ var _ Fooer = &FooerMoq{} // }, // } // -// // use mockedFooer in code that requires Fooer +// // use mockedFooer in code that requires test.Fooer // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go index 024f658e..2820ee25 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/func_args_collision_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that FuncArgsCollisionMoq does implement FuncArgsCollision. +// Ensure, that FuncArgsCollisionMoq does implement test.FuncArgsCollision. // If this is not the case, regenerate this file with moq. -var _ FuncArgsCollision = &FuncArgsCollisionMoq{} +var _ test.FuncArgsCollision = &FuncArgsCollisionMoq{} -// FuncArgsCollisionMoq is a mock implementation of FuncArgsCollision. +// FuncArgsCollisionMoq is a mock implementation of test.FuncArgsCollision. // // func TestSomethingThatUsesFuncArgsCollision(t *testing.T) { // -// // make and configure a mocked FuncArgsCollision +// // make and configure a mocked test.FuncArgsCollision // mockedFuncArgsCollision := &FuncArgsCollisionMoq{ // FooFunc: func(ret interface{}) error { // panic("mock out the Foo method") // }, // } // -// // use mockedFuncArgsCollision in code that requires FuncArgsCollision +// // use mockedFuncArgsCollision in code that requires test.FuncArgsCollision // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go index 5caf521d..29e81275 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_generic_moq.go @@ -6,25 +6,26 @@ package test import ( "sync" + test "github.com/vektra/mockery/v2/pkg/fixtures" "github.com/vektra/mockery/v2/pkg/fixtures/constraints" ) -// Ensure, that GetGenericMoq does implement GetGeneric. +// Ensure, that GetGenericMoq does implement test.GetGeneric. // If this is not the case, regenerate this file with moq. -var _ GetGeneric[int] = &GetGenericMoq[int]{} +var _ test.GetGeneric[int] = &GetGenericMoq[int]{} -// GetGenericMoq is a mock implementation of GetGeneric. +// GetGenericMoq is a mock implementation of test.GetGeneric. // // func TestSomethingThatUsesGetGeneric(t *testing.T) { // -// // make and configure a mocked GetGeneric +// // make and configure a mocked test.GetGeneric // mockedGetGeneric := &GetGenericMoq{ // GetFunc: func() T { // panic("mock out the Get method") // }, // } // -// // use mockedGetGeneric in code that requires GetGeneric +// // use mockedGetGeneric in code that requires test.GetGeneric // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go index 52bb5c9c..d7ce8417 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/get_int_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that GetIntMoq does implement GetInt. +// Ensure, that GetIntMoq does implement test.GetInt. // If this is not the case, regenerate this file with moq. -var _ GetInt = &GetIntMoq{} +var _ test.GetInt = &GetIntMoq{} -// GetIntMoq is a mock implementation of GetInt. +// GetIntMoq is a mock implementation of test.GetInt. // // func TestSomethingThatUsesGetInt(t *testing.T) { // -// // make and configure a mocked GetInt +// // make and configure a mocked test.GetInt // mockedGetInt := &GetIntMoq{ // GetFunc: func() int { // panic("mock out the Get method") // }, // } // -// // use mockedGetInt in code that requires GetInt +// // use mockedGetInt in code that requires test.GetInt // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go index 533e6e59..5f5a87c2 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/has_conflicting_nested_imports_moq.go @@ -7,18 +7,19 @@ import ( "net/http" "sync" + test "github.com/vektra/mockery/v2/pkg/fixtures" my_http "github.com/vektra/mockery/v2/pkg/fixtures/http" ) -// Ensure, that HasConflictingNestedImportsMoq does implement HasConflictingNestedImports. +// Ensure, that HasConflictingNestedImportsMoq does implement test.HasConflictingNestedImports. // If this is not the case, regenerate this file with moq. -var _ HasConflictingNestedImports = &HasConflictingNestedImportsMoq{} +var _ test.HasConflictingNestedImports = &HasConflictingNestedImportsMoq{} -// HasConflictingNestedImportsMoq is a mock implementation of HasConflictingNestedImports. +// HasConflictingNestedImportsMoq is a mock implementation of test.HasConflictingNestedImports. // // func TestSomethingThatUsesHasConflictingNestedImports(t *testing.T) { // -// // make and configure a mocked HasConflictingNestedImports +// // make and configure a mocked test.HasConflictingNestedImports // mockedHasConflictingNestedImports := &HasConflictingNestedImportsMoq{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") @@ -28,7 +29,7 @@ var _ HasConflictingNestedImports = &HasConflictingNestedImportsMoq{} // }, // } // -// // use mockedHasConflictingNestedImports in code that requires HasConflictingNestedImports +// // use mockedHasConflictingNestedImports in code that requires test.HasConflictingNestedImports // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go index 2910ead4..35f7b809 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/imports_same_as_package_moq.go @@ -10,15 +10,15 @@ import ( redefinedtypeb "github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b" ) -// Ensure, that ImportsSameAsPackageMoq does implement ImportsSameAsPackage. +// Ensure, that ImportsSameAsPackageMoq does implement fixtures.ImportsSameAsPackage. // If this is not the case, regenerate this file with moq. -var _ ImportsSameAsPackage = &ImportsSameAsPackageMoq{} +var _ fixtures.ImportsSameAsPackage = &ImportsSameAsPackageMoq{} -// ImportsSameAsPackageMoq is a mock implementation of ImportsSameAsPackage. +// ImportsSameAsPackageMoq is a mock implementation of fixtures.ImportsSameAsPackage. // // func TestSomethingThatUsesImportsSameAsPackage(t *testing.T) { // -// // make and configure a mocked ImportsSameAsPackage +// // make and configure a mocked fixtures.ImportsSameAsPackage // mockedImportsSameAsPackage := &ImportsSameAsPackageMoq{ // AFunc: func() redefinedtypeb.B { // panic("mock out the A method") @@ -31,7 +31,7 @@ var _ ImportsSameAsPackage = &ImportsSameAsPackageMoq{} // }, // } // -// // use mockedImportsSameAsPackage in code that requires ImportsSameAsPackage +// // use mockedImportsSameAsPackage in code that requires fixtures.ImportsSameAsPackage // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go index 14936130..83f7c218 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/key_manager_moq.go @@ -9,22 +9,22 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that KeyManagerMoq does implement KeyManager. +// Ensure, that KeyManagerMoq does implement test.KeyManager. // If this is not the case, regenerate this file with moq. -var _ KeyManager = &KeyManagerMoq{} +var _ test.KeyManager = &KeyManagerMoq{} -// KeyManagerMoq is a mock implementation of KeyManager. +// KeyManagerMoq is a mock implementation of test.KeyManager. // // func TestSomethingThatUsesKeyManager(t *testing.T) { // -// // make and configure a mocked KeyManager +// // make and configure a mocked test.KeyManager // mockedKeyManager := &KeyManagerMoq{ // GetKeyFunc: func(s string, v uint16) ([]byte, *test.Err) { // panic("mock out the GetKey method") // }, // } // -// // use mockedKeyManager in code that requires KeyManager +// // use mockedKeyManager in code that requires test.KeyManager // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go index 456df057..0af0021e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_func_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MapFuncMoq does implement MapFunc. +// Ensure, that MapFuncMoq does implement test.MapFunc. // If this is not the case, regenerate this file with moq. -var _ MapFunc = &MapFuncMoq{} +var _ test.MapFunc = &MapFuncMoq{} -// MapFuncMoq is a mock implementation of MapFunc. +// MapFuncMoq is a mock implementation of test.MapFunc. // // func TestSomethingThatUsesMapFunc(t *testing.T) { // -// // make and configure a mocked MapFunc +// // make and configure a mocked test.MapFunc // mockedMapFunc := &MapFuncMoq{ // GetFunc: func(m map[string]func(string) string) error { // panic("mock out the Get method") // }, // } // -// // use mockedMapFunc in code that requires MapFunc +// // use mockedMapFunc in code that requires test.MapFunc // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go index 9526235c..189d4a64 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/map_to_interface_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MapToInterfaceMoq does implement MapToInterface. +// Ensure, that MapToInterfaceMoq does implement test.MapToInterface. // If this is not the case, regenerate this file with moq. -var _ MapToInterface = &MapToInterfaceMoq{} +var _ test.MapToInterface = &MapToInterfaceMoq{} -// MapToInterfaceMoq is a mock implementation of MapToInterface. +// MapToInterfaceMoq is a mock implementation of test.MapToInterface. // // func TestSomethingThatUsesMapToInterface(t *testing.T) { // -// // make and configure a mocked MapToInterface +// // make and configure a mocked test.MapToInterface // mockedMapToInterface := &MapToInterfaceMoq{ // FooFunc: func(arg1 ...map[string]interface{}) { // panic("mock out the Foo method") // }, // } // -// // use mockedMapToInterface in code that requires MapToInterface +// // use mockedMapToInterface in code that requires test.MapToInterface // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go index 6f83b501..0d328d84 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/my_reader_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that MyReaderMoq does implement MyReader. +// Ensure, that MyReaderMoq does implement test.MyReader. // If this is not the case, regenerate this file with moq. -var _ MyReader = &MyReaderMoq{} +var _ test.MyReader = &MyReaderMoq{} -// MyReaderMoq is a mock implementation of MyReader. +// MyReaderMoq is a mock implementation of test.MyReader. // // func TestSomethingThatUsesMyReader(t *testing.T) { // -// // make and configure a mocked MyReader +// // make and configure a mocked test.MyReader // mockedMyReader := &MyReaderMoq{ // ReadFunc: func(p []byte) (int, error) { // panic("mock out the Read method") // }, // } // -// // use mockedMyReader in code that requires MyReader +// // use mockedMyReader in code that requires test.MyReader // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go index f279eee1..d514e4c7 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/panic_on_no_return_value_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that PanicOnNoReturnValueMoq does implement PanicOnNoReturnValue. +// Ensure, that PanicOnNoReturnValueMoq does implement test.PanicOnNoReturnValue. // If this is not the case, regenerate this file with moq. -var _ PanicOnNoReturnValue = &PanicOnNoReturnValueMoq{} +var _ test.PanicOnNoReturnValue = &PanicOnNoReturnValueMoq{} -// PanicOnNoReturnValueMoq is a mock implementation of PanicOnNoReturnValue. +// PanicOnNoReturnValueMoq is a mock implementation of test.PanicOnNoReturnValue. // // func TestSomethingThatUsesPanicOnNoReturnValue(t *testing.T) { // -// // make and configure a mocked PanicOnNoReturnValue +// // make and configure a mocked test.PanicOnNoReturnValue // mockedPanicOnNoReturnValue := &PanicOnNoReturnValueMoq{ // DoSomethingFunc: func() string { // panic("mock out the DoSomething method") // }, // } // -// // use mockedPanicOnNoReturnValue in code that requires PanicOnNoReturnValue +// // use mockedPanicOnNoReturnValue in code that requires test.PanicOnNoReturnValue // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go index 3385a629..ac3bb093 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester2_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester2Moq does implement Requester2. +// Ensure, that Requester2Moq does implement test.Requester2. // If this is not the case, regenerate this file with moq. -var _ Requester2 = &Requester2Moq{} +var _ test.Requester2 = &Requester2Moq{} -// Requester2Moq is a mock implementation of Requester2. +// Requester2Moq is a mock implementation of test.Requester2. // // func TestSomethingThatUsesRequester2(t *testing.T) { // -// // make and configure a mocked Requester2 +// // make and configure a mocked test.Requester2 // mockedRequester2 := &Requester2Moq{ // GetFunc: func(path string) error { // panic("mock out the Get method") // }, // } // -// // use mockedRequester2 in code that requires Requester2 +// // use mockedRequester2 in code that requires test.Requester2 // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go index dab971dd..f06eea24 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester3_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester3Moq does implement Requester3. +// Ensure, that Requester3Moq does implement test.Requester3. // If this is not the case, regenerate this file with moq. -var _ Requester3 = &Requester3Moq{} +var _ test.Requester3 = &Requester3Moq{} -// Requester3Moq is a mock implementation of Requester3. +// Requester3Moq is a mock implementation of test.Requester3. // // func TestSomethingThatUsesRequester3(t *testing.T) { // -// // make and configure a mocked Requester3 +// // make and configure a mocked test.Requester3 // mockedRequester3 := &Requester3Moq{ // GetFunc: func() error { // panic("mock out the Get method") // }, // } // -// // use mockedRequester3 in code that requires Requester3 +// // use mockedRequester3 in code that requires test.Requester3 // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go index 94b960bc..be7e73fb 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester4_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that Requester4Moq does implement Requester4. +// Ensure, that Requester4Moq does implement test.Requester4. // If this is not the case, regenerate this file with moq. -var _ Requester4 = &Requester4Moq{} +var _ test.Requester4 = &Requester4Moq{} -// Requester4Moq is a mock implementation of Requester4. +// Requester4Moq is a mock implementation of test.Requester4. // // func TestSomethingThatUsesRequester4(t *testing.T) { // -// // make and configure a mocked Requester4 +// // make and configure a mocked test.Requester4 // mockedRequester4 := &Requester4Moq{ // GetFunc: func() { // panic("mock out the Get method") // }, // } // -// // use mockedRequester4 in code that requires Requester4 +// // use mockedRequester4 in code that requires test.Requester4 // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go index 39a7a5a8..08cb516e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_import_moq.go @@ -6,24 +6,26 @@ package test import ( "encoding/json" "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsImportMoq does implement RequesterArgSameAsImport. +// Ensure, that RequesterArgSameAsImportMoq does implement test.RequesterArgSameAsImport. // If this is not the case, regenerate this file with moq. -var _ RequesterArgSameAsImport = &RequesterArgSameAsImportMoq{} +var _ test.RequesterArgSameAsImport = &RequesterArgSameAsImportMoq{} -// RequesterArgSameAsImportMoq is a mock implementation of RequesterArgSameAsImport. +// RequesterArgSameAsImportMoq is a mock implementation of test.RequesterArgSameAsImport. // // func TestSomethingThatUsesRequesterArgSameAsImport(t *testing.T) { // -// // make and configure a mocked RequesterArgSameAsImport +// // make and configure a mocked test.RequesterArgSameAsImport // mockedRequesterArgSameAsImport := &RequesterArgSameAsImportMoq{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsImport in code that requires RequesterArgSameAsImport +// // use mockedRequesterArgSameAsImport in code that requires test.RequesterArgSameAsImport // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go index a4f1f291..62fd34d5 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_named_import_moq.go @@ -6,24 +6,26 @@ package test import ( "encoding/json" "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsNamedImportMoq does implement RequesterArgSameAsNamedImport. +// Ensure, that RequesterArgSameAsNamedImportMoq does implement test.RequesterArgSameAsNamedImport. // If this is not the case, regenerate this file with moq. -var _ RequesterArgSameAsNamedImport = &RequesterArgSameAsNamedImportMoq{} +var _ test.RequesterArgSameAsNamedImport = &RequesterArgSameAsNamedImportMoq{} -// RequesterArgSameAsNamedImportMoq is a mock implementation of RequesterArgSameAsNamedImport. +// RequesterArgSameAsNamedImportMoq is a mock implementation of test.RequesterArgSameAsNamedImport. // // func TestSomethingThatUsesRequesterArgSameAsNamedImport(t *testing.T) { // -// // make and configure a mocked RequesterArgSameAsNamedImport +// // make and configure a mocked test.RequesterArgSameAsNamedImport // mockedRequesterArgSameAsNamedImport := &RequesterArgSameAsNamedImportMoq{ // GetFunc: func(jsonMoqParam string) *json.RawMessage { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsNamedImport in code that requires RequesterArgSameAsNamedImport +// // use mockedRequesterArgSameAsNamedImport in code that requires test.RequesterArgSameAsNamedImport // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go index 6ee83028..be67ec3c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_arg_same_as_pkg_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArgSameAsPkgMoq does implement RequesterArgSameAsPkg. +// Ensure, that RequesterArgSameAsPkgMoq does implement test.RequesterArgSameAsPkg. // If this is not the case, regenerate this file with moq. -var _ RequesterArgSameAsPkg = &RequesterArgSameAsPkgMoq{} +var _ test.RequesterArgSameAsPkg = &RequesterArgSameAsPkgMoq{} -// RequesterArgSameAsPkgMoq is a mock implementation of RequesterArgSameAsPkg. +// RequesterArgSameAsPkgMoq is a mock implementation of test.RequesterArgSameAsPkg. // // func TestSomethingThatUsesRequesterArgSameAsPkg(t *testing.T) { // -// // make and configure a mocked RequesterArgSameAsPkg +// // make and configure a mocked test.RequesterArgSameAsPkg // mockedRequesterArgSameAsPkg := &RequesterArgSameAsPkgMoq{ // GetFunc: func(test string) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArgSameAsPkg in code that requires RequesterArgSameAsPkg +// // use mockedRequesterArgSameAsPkg in code that requires test.RequesterArgSameAsPkg // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go index 9cf31280..1ac10162 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_array_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterArrayMoq does implement RequesterArray. +// Ensure, that RequesterArrayMoq does implement test.RequesterArray. // If this is not the case, regenerate this file with moq. -var _ RequesterArray = &RequesterArrayMoq{} +var _ test.RequesterArray = &RequesterArrayMoq{} -// RequesterArrayMoq is a mock implementation of RequesterArray. +// RequesterArrayMoq is a mock implementation of test.RequesterArray. // // func TestSomethingThatUsesRequesterArray(t *testing.T) { // -// // make and configure a mocked RequesterArray +// // make and configure a mocked test.RequesterArray // mockedRequesterArray := &RequesterArrayMoq{ // GetFunc: func(path string) ([2]string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterArray in code that requires RequesterArray +// // use mockedRequesterArray in code that requires test.RequesterArray // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go index f4d02b26..edf1f8ed 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_elided_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterElidedMoq does implement RequesterElided. +// Ensure, that RequesterElidedMoq does implement test.RequesterElided. // If this is not the case, regenerate this file with moq. -var _ RequesterElided = &RequesterElidedMoq{} +var _ test.RequesterElided = &RequesterElidedMoq{} -// RequesterElidedMoq is a mock implementation of RequesterElided. +// RequesterElidedMoq is a mock implementation of test.RequesterElided. // // func TestSomethingThatUsesRequesterElided(t *testing.T) { // -// // make and configure a mocked RequesterElided +// // make and configure a mocked test.RequesterElided // mockedRequesterElided := &RequesterElidedMoq{ // GetFunc: func(path string, url string) error { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterElided in code that requires RequesterElided +// // use mockedRequesterElided in code that requires test.RequesterElided // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go index 7181d378..1a6351f0 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_iface_moq.go @@ -6,24 +6,26 @@ package test import ( "io" "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterIfaceMoq does implement RequesterIface. +// Ensure, that RequesterIfaceMoq does implement test.RequesterIface. // If this is not the case, regenerate this file with moq. -var _ RequesterIface = &RequesterIfaceMoq{} +var _ test.RequesterIface = &RequesterIfaceMoq{} -// RequesterIfaceMoq is a mock implementation of RequesterIface. +// RequesterIfaceMoq is a mock implementation of test.RequesterIface. // // func TestSomethingThatUsesRequesterIface(t *testing.T) { // -// // make and configure a mocked RequesterIface +// // make and configure a mocked test.RequesterIface // mockedRequesterIface := &RequesterIfaceMoq{ // GetFunc: func() io.Reader { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterIface in code that requires RequesterIface +// // use mockedRequesterIface in code that requires test.RequesterIface // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go index 8e7a113d..6386b78c 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterMoq does implement Requester. +// Ensure, that RequesterMoq does implement test.Requester. // If this is not the case, regenerate this file with moq. -var _ Requester = &RequesterMoq{} +var _ test.Requester = &RequesterMoq{} -// RequesterMoq is a mock implementation of Requester. +// RequesterMoq is a mock implementation of test.Requester. // // func TestSomethingThatUsesRequester(t *testing.T) { // -// // make and configure a mocked Requester +// // make and configure a mocked test.Requester // mockedRequester := &RequesterMoq{ // GetFunc: func(path string) (string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequester in code that requires Requester +// // use mockedRequester in code that requires test.Requester // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go index 2dc1bd45..241eedb0 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ns_moq.go @@ -6,24 +6,26 @@ package test import ( "net/http" "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterNSMoq does implement RequesterNS. +// Ensure, that RequesterNSMoq does implement test.RequesterNS. // If this is not the case, regenerate this file with moq. -var _ RequesterNS = &RequesterNSMoq{} +var _ test.RequesterNS = &RequesterNSMoq{} -// RequesterNSMoq is a mock implementation of RequesterNS. +// RequesterNSMoq is a mock implementation of test.RequesterNS. // // func TestSomethingThatUsesRequesterNS(t *testing.T) { // -// // make and configure a mocked RequesterNS +// // make and configure a mocked test.RequesterNS // mockedRequesterNS := &RequesterNSMoq{ // GetFunc: func(path string) (http.Response, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterNS in code that requires RequesterNS +// // use mockedRequesterNS in code that requires test.RequesterNS // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go index 0b796d16..2a26999f 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_ptr_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterPtrMoq does implement RequesterPtr. +// Ensure, that RequesterPtrMoq does implement test.RequesterPtr. // If this is not the case, regenerate this file with moq. -var _ RequesterPtr = &RequesterPtrMoq{} +var _ test.RequesterPtr = &RequesterPtrMoq{} -// RequesterPtrMoq is a mock implementation of RequesterPtr. +// RequesterPtrMoq is a mock implementation of test.RequesterPtr. // // func TestSomethingThatUsesRequesterPtr(t *testing.T) { // -// // make and configure a mocked RequesterPtr +// // make and configure a mocked test.RequesterPtr // mockedRequesterPtr := &RequesterPtrMoq{ // GetFunc: func(path string) (*string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterPtr in code that requires RequesterPtr +// // use mockedRequesterPtr in code that requires test.RequesterPtr // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go index 27afd010..c4ab5175 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_return_elided_moq.go @@ -5,17 +5,19 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterReturnElidedMoq does implement RequesterReturnElided. +// Ensure, that RequesterReturnElidedMoq does implement test.RequesterReturnElided. // If this is not the case, regenerate this file with moq. -var _ RequesterReturnElided = &RequesterReturnElidedMoq{} +var _ test.RequesterReturnElided = &RequesterReturnElidedMoq{} -// RequesterReturnElidedMoq is a mock implementation of RequesterReturnElided. +// RequesterReturnElidedMoq is a mock implementation of test.RequesterReturnElided. // // func TestSomethingThatUsesRequesterReturnElided(t *testing.T) { // -// // make and configure a mocked RequesterReturnElided +// // make and configure a mocked test.RequesterReturnElided // mockedRequesterReturnElided := &RequesterReturnElidedMoq{ // GetFunc: func(path string) (int, int, int, error) { // panic("mock out the Get method") @@ -25,7 +27,7 @@ var _ RequesterReturnElided = &RequesterReturnElidedMoq{} // }, // } // -// // use mockedRequesterReturnElided in code that requires RequesterReturnElided +// // use mockedRequesterReturnElided in code that requires test.RequesterReturnElided // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go index c33ad449..d0f8d1b7 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_slice_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterSliceMoq does implement RequesterSlice. +// Ensure, that RequesterSliceMoq does implement test.RequesterSlice. // If this is not the case, regenerate this file with moq. -var _ RequesterSlice = &RequesterSliceMoq{} +var _ test.RequesterSlice = &RequesterSliceMoq{} -// RequesterSliceMoq is a mock implementation of RequesterSlice. +// RequesterSliceMoq is a mock implementation of test.RequesterSlice. // // func TestSomethingThatUsesRequesterSlice(t *testing.T) { // -// // make and configure a mocked RequesterSlice +// // make and configure a mocked test.RequesterSlice // mockedRequesterSlice := &RequesterSliceMoq{ // GetFunc: func(path string) ([]string, error) { // panic("mock out the Get method") // }, // } // -// // use mockedRequesterSlice in code that requires RequesterSlice +// // use mockedRequesterSlice in code that requires test.RequesterSlice // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go index 94a4ae31..cb77f4e9 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/requester_variadic_moq.go @@ -6,17 +6,19 @@ package test import ( "io" "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that RequesterVariadicMoq does implement RequesterVariadic. +// Ensure, that RequesterVariadicMoq does implement test.RequesterVariadic. // If this is not the case, regenerate this file with moq. -var _ RequesterVariadic = &RequesterVariadicMoq{} +var _ test.RequesterVariadic = &RequesterVariadicMoq{} -// RequesterVariadicMoq is a mock implementation of RequesterVariadic. +// RequesterVariadicMoq is a mock implementation of test.RequesterVariadic. // // func TestSomethingThatUsesRequesterVariadic(t *testing.T) { // -// // make and configure a mocked RequesterVariadic +// // make and configure a mocked test.RequesterVariadic // mockedRequesterVariadic := &RequesterVariadicMoq{ // GetFunc: func(values ...string) bool { // panic("mock out the Get method") @@ -32,7 +34,7 @@ var _ RequesterVariadic = &RequesterVariadicMoq{} // }, // } // -// // use mockedRequesterVariadic in code that requires RequesterVariadic +// // use mockedRequesterVariadic in code that requires test.RequesterVariadic // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go index c845c33e..ef82d0d8 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/sibling_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that SiblingMoq does implement Sibling. +// Ensure, that SiblingMoq does implement test.Sibling. // If this is not the case, regenerate this file with moq. -var _ Sibling = &SiblingMoq{} +var _ test.Sibling = &SiblingMoq{} -// SiblingMoq is a mock implementation of Sibling. +// SiblingMoq is a mock implementation of test.Sibling. // // func TestSomethingThatUsesSibling(t *testing.T) { // -// // make and configure a mocked Sibling +// // make and configure a mocked test.Sibling // mockedSibling := &SiblingMoq{ // DoSomethingFunc: func() { // panic("mock out the DoSomething method") // }, // } // -// // use mockedSibling in code that requires Sibling +// // use mockedSibling in code that requires test.Sibling // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go index f42a0364..b0a5dd5b 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/struct_with_tag_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that StructWithTagMoq does implement StructWithTag. +// Ensure, that StructWithTagMoq does implement test.StructWithTag. // If this is not the case, regenerate this file with moq. -var _ StructWithTag = &StructWithTagMoq{} +var _ test.StructWithTag = &StructWithTagMoq{} -// StructWithTagMoq is a mock implementation of StructWithTag. +// StructWithTagMoq is a mock implementation of test.StructWithTag. // // func TestSomethingThatUsesStructWithTag(t *testing.T) { // -// // make and configure a mocked StructWithTag +// // make and configure a mocked test.StructWithTag // mockedStructWithTag := &StructWithTagMoq{ // MethodAFunc: func(v *struct{FieldA int "json:\"field_a\""; FieldB int "json:\"field_b\" xml:\"field_b\""}) *struct{FieldC int "json:\"field_c\""; FieldD int "json:\"field_d\" xml:\"field_d\""} { // panic("mock out the MethodA method") // }, // } // -// // use mockedStructWithTag in code that requires StructWithTag +// // use mockedStructWithTag in code that requires test.StructWithTag // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go index d9f03945..918489f8 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/uses_other_pkg_iface_moq.go @@ -9,22 +9,22 @@ import ( test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that UsesOtherPkgIfaceMoq does implement UsesOtherPkgIface. +// Ensure, that UsesOtherPkgIfaceMoq does implement test.UsesOtherPkgIface. // If this is not the case, regenerate this file with moq. -var _ UsesOtherPkgIface = &UsesOtherPkgIfaceMoq{} +var _ test.UsesOtherPkgIface = &UsesOtherPkgIfaceMoq{} -// UsesOtherPkgIfaceMoq is a mock implementation of UsesOtherPkgIface. +// UsesOtherPkgIfaceMoq is a mock implementation of test.UsesOtherPkgIface. // // func TestSomethingThatUsesUsesOtherPkgIface(t *testing.T) { // -// // make and configure a mocked UsesOtherPkgIface +// // make and configure a mocked test.UsesOtherPkgIface // mockedUsesOtherPkgIface := &UsesOtherPkgIfaceMoq{ // DoSomethingElseFunc: func(obj test.Sibling) { // panic("mock out the DoSomethingElse method") // }, // } // -// // use mockedUsesOtherPkgIface in code that requires UsesOtherPkgIface +// // use mockedUsesOtherPkgIface in code that requires test.UsesOtherPkgIface // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go index 5167dde5..26cd085e 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that VariadicMoq does implement Variadic. +// Ensure, that VariadicMoq does implement test.Variadic. // If this is not the case, regenerate this file with moq. -var _ Variadic = &VariadicMoq{} +var _ test.Variadic = &VariadicMoq{} -// VariadicMoq is a mock implementation of Variadic. +// VariadicMoq is a mock implementation of test.Variadic. // // func TestSomethingThatUsesVariadic(t *testing.T) { // -// // make and configure a mocked Variadic +// // make and configure a mocked test.Variadic // mockedVariadic := &VariadicMoq{ // VariadicFunctionFunc: func(str string, vFunc func(args1 string, args2 ...interface{}) interface{}) error { // panic("mock out the VariadicFunction method") // }, // } // -// // use mockedVariadic in code that requires Variadic +// // use mockedVariadic in code that requires test.Variadic // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go index 5818d8a8..6b10bc32 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_no_return_interface_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that VariadicNoReturnInterfaceMoq does implement VariadicNoReturnInterface. +// Ensure, that VariadicNoReturnInterfaceMoq does implement test.VariadicNoReturnInterface. // If this is not the case, regenerate this file with moq. -var _ VariadicNoReturnInterface = &VariadicNoReturnInterfaceMoq{} +var _ test.VariadicNoReturnInterface = &VariadicNoReturnInterfaceMoq{} -// VariadicNoReturnInterfaceMoq is a mock implementation of VariadicNoReturnInterface. +// VariadicNoReturnInterfaceMoq is a mock implementation of test.VariadicNoReturnInterface. // // func TestSomethingThatUsesVariadicNoReturnInterface(t *testing.T) { // -// // make and configure a mocked VariadicNoReturnInterface +// // make and configure a mocked test.VariadicNoReturnInterface // mockedVariadicNoReturnInterface := &VariadicNoReturnInterfaceMoq{ // VariadicNoReturnFunc: func(j int, is ...interface{}) { // panic("mock out the VariadicNoReturn method") // }, // } // -// // use mockedVariadicNoReturnInterface in code that requires VariadicNoReturnInterface +// // use mockedVariadicNoReturnInterface in code that requires test.VariadicNoReturnInterface // // and then make assertions. // // } diff --git a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go index b6bee662..7b4c2f42 100644 --- a/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go +++ b/mocks/moq/github.com/vektra/mockery/v2/pkg/fixtures/variadic_return_func_moq.go @@ -5,24 +5,26 @@ package test import ( "sync" + + test "github.com/vektra/mockery/v2/pkg/fixtures" ) -// Ensure, that VariadicReturnFuncMoq does implement VariadicReturnFunc. +// Ensure, that VariadicReturnFuncMoq does implement test.VariadicReturnFunc. // If this is not the case, regenerate this file with moq. -var _ VariadicReturnFunc = &VariadicReturnFuncMoq{} +var _ test.VariadicReturnFunc = &VariadicReturnFuncMoq{} -// VariadicReturnFuncMoq is a mock implementation of VariadicReturnFunc. +// VariadicReturnFuncMoq is a mock implementation of test.VariadicReturnFunc. // // func TestSomethingThatUsesVariadicReturnFunc(t *testing.T) { // -// // make and configure a mocked VariadicReturnFunc +// // make and configure a mocked test.VariadicReturnFunc // mockedVariadicReturnFunc := &VariadicReturnFuncMoq{ // SampleMethodFunc: func(str string) func(str string, arr []int, a ...interface{}) { // panic("mock out the SampleMethod method") // }, // } // -// // use mockedVariadicReturnFunc in code that requires VariadicReturnFunc +// // use mockedVariadicReturnFunc in code that requires test.VariadicReturnFunc // // and then make assertions. // // } From c8a230424e418229a230e37941408c48de859571 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 21 Feb 2024 14:38:29 -0600 Subject: [PATCH 47/50] change codecov threshold to 0 --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 854ad482..49ecf7af 100644 --- a/codecov.yml +++ b/codecov.yml @@ -5,7 +5,7 @@ coverage: status: patch: default: - target: 40% + target: 0% threshold: 35% base: auto From 37562c587e407fac8eaec4c32718b23bb6aacb08 Mon Sep 17 00:00:00 2001 From: LandonTClipp <11232769+LandonTClipp@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:53:31 -0600 Subject: [PATCH 48/50] updates --- codecov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 49ecf7af..5aaedb3e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -8,4 +8,3 @@ coverage: target: 0% threshold: 35% base: auto - From 4ddd30ba4c5dd61279072d6027a8b0d44e381568 Mon Sep 17 00:00:00 2001 From: LandonTClipp <11232769+LandonTClipp@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:02:53 -0600 Subject: [PATCH 49/50] reduce codecov patch requirement to 0 --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 5aaedb3e..b6b63e08 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,7 +1,7 @@ coverage: precision: 5 round: down - range: "40...100" + range: "0...100" status: patch: default: From 8ff0a852154a64c322e2cbcc802ba40d35a7069d Mon Sep 17 00:00:00 2001 From: LandonTClipp <11232769+LandonTClipp@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:10:41 -0600 Subject: [PATCH 50/50] fix codecov project target --- codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codecov.yml b/codecov.yml index b6b63e08..1cc5d886 100644 --- a/codecov.yml +++ b/codecov.yml @@ -4,6 +4,11 @@ coverage: range: "0...100" status: patch: + default: + target: 0% + threshold: 35% + base: auto + project: default: target: 0% threshold: 35%