diff --git a/README.md b/README.md index 34ce210..f7425de 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,11 @@ The mocked structure implements the interface, where each method calls the assoc You can run the same command with `-fmt noop` to print the generated source code without attempting to format it. This can aid in debugging the root cause. +## Development + +- This project uses + - https://pkg.go.dev/text/template + ## License The Moq project (and all code) is licensed under the [MIT License](LICENSE). diff --git a/example/mockpersonstore_test.go b/example/mockpersonstore_test.go index 70911cd..1e77dc7 100755 --- a/example/mockpersonstore_test.go +++ b/example/mockpersonstore_test.go @@ -14,23 +14,30 @@ var _ PersonStore = &PersonStoreMock{} // PersonStoreMock is a mock implementation of PersonStore. // -// func TestSomethingThatUsesPersonStore(t *testing.T) { +// func TestSomethingThatUsesPersonStore(t *testing.T) { // -// // make and configure a mocked PersonStore -// mockedPersonStore := &PersonStoreMock{ -// CreateFunc: func(ctx context.Context, person *Person, confirm bool) error { -// panic("mock out the Create method") -// }, -// GetFunc: func(ctx context.Context, id string) (*Person, error) { -// panic("mock out the Get method") -// }, -// } +// // make and configure a mocked PersonStore +// mockedPersonStore := &PersonStoreMock{ +// ClearCacheFunc: func(id string) { +// panic("mock out the ClearCache method") +// }, +// CreateFunc: func(ctx context.Context, person *Person, confirm bool) error { +// panic("mock out the Create method") +// }, +// GetFunc: func(ctx context.Context, id string) (*Person, error) { +// panic("mock out the Get method") +// }, +// } // -// // use mockedPersonStore in code that requires PersonStore -// // and then make assertions. +// // use mockedPersonStore in code that requires PersonStore +// // and then make assertions. // -// } +// } + type PersonStoreMock struct { + // ClearCacheFunc mocks the ClearCache method. + ClearCacheFunc func(id string) + // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, person *Person, confirm bool) error @@ -39,25 +46,66 @@ type PersonStoreMock struct { // calls tracks calls to the methods. calls struct { + // ClearCache holds details about calls to the ClearCache method. + ClearCache []PersonStoreMockClearCacheCalls // Create holds details about calls to the Create method. - Create []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // Person is the person argument value. - Person *Person - // Confirm is the confirm argument value. - Confirm bool - } + Create []PersonStoreMockCreateCalls // Get holds details about calls to the Get method. - Get []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID string - } + Get []PersonStoreMockGetCalls + } + lockClearCache sync.RWMutex + lockCreate sync.RWMutex + lockGet sync.RWMutex +} + +// PersonStoreMockClearCacheCalls holds details about calls to the ClearCache method. +type PersonStoreMockClearCacheCalls struct { + // ID is the id argument value. + ID string +} + +// PersonStoreMockCreateCalls holds details about calls to the Create method. +type PersonStoreMockCreateCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Person is the person argument value. + Person *Person + // Confirm is the confirm argument value. + Confirm bool +} + +// PersonStoreMockGetCalls holds details about calls to the Get method. +type PersonStoreMockGetCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID string +} + +// ClearCache calls ClearCacheFunc. +func (mock *PersonStoreMock) ClearCache(id string) { + if mock.ClearCacheFunc == nil { + panic("PersonStoreMock.ClearCacheFunc: method is nil but PersonStore.ClearCache was just called") + } + callInfo := PersonStoreMockClearCacheCalls{ + ID: id, } - lockCreate sync.RWMutex - lockGet sync.RWMutex + mock.lockClearCache.Lock() + mock.calls.ClearCache = append(mock.calls.ClearCache, callInfo) + mock.lockClearCache.Unlock() + mock.ClearCacheFunc(id) +} + +// ClearCacheCalls gets all the calls that were made to ClearCache. +// Check the length with: +// +// len(mockedPersonStore.ClearCacheCalls()) +func (mock *PersonStoreMock) ClearCacheCalls() []PersonStoreMockClearCacheCalls { + var calls []PersonStoreMockClearCacheCalls + mock.lockClearCache.RLock() + calls = mock.calls.ClearCache + mock.lockClearCache.RUnlock() + return calls } // Create calls CreateFunc. @@ -65,11 +113,7 @@ func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm if mock.CreateFunc == nil { panic("PersonStoreMock.CreateFunc: method is nil but PersonStore.Create was just called") } - callInfo := struct { - Ctx context.Context - Person *Person - Confirm bool - }{ + callInfo := PersonStoreMockCreateCalls{ Ctx: ctx, Person: person, Confirm: confirm, @@ -82,17 +126,10 @@ func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm // CreateCalls gets all the calls that were made to Create. // Check the length with: -// len(mockedPersonStore.CreateCalls()) -func (mock *PersonStoreMock) CreateCalls() []struct { - Ctx context.Context - Person *Person - Confirm bool -} { - var calls []struct { - Ctx context.Context - Person *Person - Confirm bool - } +// +// len(mockedPersonStore.CreateCalls()) +func (mock *PersonStoreMock) CreateCalls() []PersonStoreMockCreateCalls { + var calls []PersonStoreMockCreateCalls mock.lockCreate.RLock() calls = mock.calls.Create mock.lockCreate.RUnlock() @@ -104,10 +141,7 @@ func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error if mock.GetFunc == nil { panic("PersonStoreMock.GetFunc: method is nil but PersonStore.Get was just called") } - callInfo := struct { - Ctx context.Context - ID string - }{ + callInfo := PersonStoreMockGetCalls{ Ctx: ctx, ID: id, } @@ -119,15 +153,10 @@ func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error // GetCalls gets all the calls that were made to Get. // Check the length with: -// len(mockedPersonStore.GetCalls()) -func (mock *PersonStoreMock) GetCalls() []struct { - Ctx context.Context - ID string -} { - var calls []struct { - Ctx context.Context - ID string - } +// +// len(mockedPersonStore.GetCalls()) +func (mock *PersonStoreMock) GetCalls() []PersonStoreMockGetCalls { + var calls []PersonStoreMockGetCalls mock.lockGet.RLock() calls = mock.calls.Get mock.lockGet.RUnlock() diff --git a/example/usage.go b/example/usage.go new file mode 100644 index 0000000..7c3dd85 --- /dev/null +++ b/example/usage.go @@ -0,0 +1,17 @@ +package example + +import "context" + +type Service struct { + PersonStore PersonStore +} + +func NewService(personStore PersonStore) *Service { + return &Service{ + PersonStore: personStore, + } +} + +func (s *Service) GetPerson(ctx context.Context, id string) (*Person, error) { + return s.PersonStore.Get(ctx, id) +} diff --git a/example/usage_test.go b/example/usage_test.go new file mode 100644 index 0000000..dd00daa --- /dev/null +++ b/example/usage_test.go @@ -0,0 +1,33 @@ +package example + +import ( + "context" + "reflect" + "testing" +) + +func TestService_GetPerson(t *testing.T) { + ctx := context.Background() + personStore := &PersonStoreMock{ + GetFunc: func(ctx context.Context, id string) (*Person, error) { + return &Person{ + ID: "1", + Name: "John Doe", + }, nil + }, + } + s := NewService(personStore) + // When + s.GetPerson(ctx, "1") + // Then + actual := personStore.GetCalls() + expected := []PersonStoreMockGetCalls{ + { + Ctx: ctx, + ID: "1", + }, + } + if !reflect.DeepEqual(expected, actual) { + t.Fatalf("Expected %v but got %v", expected, actual) + } +} diff --git a/internal/template/template.go b/internal/template/template.go index 9e2672c..333971f 100644 --- a/internal/template/template.go +++ b/internal/template/template.go @@ -1,6 +1,7 @@ package template import ( + _ "embed" "io" "strings" "text/template" @@ -32,177 +33,9 @@ func (t Template) Execute(w io.Writer, data Data) error { // 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 -}} - {{- 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}}. -// -// 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}} -{{- 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}} -{{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}} -{{- 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") - } -{{- 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}} -{{- 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}} - } { - var calls []struct { - {{- range .Params}} - {{.Name | Exported}} {{.TypeString}} - {{- end}} - } - mock.lock{{.Name}}.RLock() - calls = mock.calls.{{.Name}} - 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 -}} -` +//go:embed template.gohtml +var moqTemplate string // 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.gohtml b/internal/template/template.gohtml new file mode 100644 index 0000000..c868d5c --- /dev/null +++ b/internal/template/template.gohtml @@ -0,0 +1,194 @@ +// 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 -}} + {{- 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}}. + // + // 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. + // + // } + {{/* Begin of main type 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}} + {{end}} + // calls tracks calls to the methods. + calls struct { + {{- range .Methods}} + // {{.Name}} holds details about calls to the {{.Name}} method. + {{.Name}} []{{$mock.MockName}}{{.Name}}Calls + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] + {{- end }} + {{- end}} + } + {{- range .Methods}} + lock{{.Name}} {{$.Imports | SyncPkgQualifier}}.RWMutex + {{- end}} + } + {{/* End of main type struct */}} + {{/* Begin of calls type struct */}} + {{- range .Methods}} + // {{$mock.MockName}}{{.Name}}Calls holds details about calls to the {{.Name}} method. + type {{$mock.MockName}}{{.Name}}Calls + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} {{$param.TypeString}} + {{- end -}}] + {{- end }} struct { + {{- range .Params}} + // {{.Name | Exported}} is the {{.Name}} argument value. + {{.Name | Exported}} {{.TypeString}} + {{- end}} + } + {{- end}} + {{/* End of main type */}} + + {{/* Begin of functions */}} + {{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}} + if mock.{{.Name}}Func == nil { + panic("{{$mock.MockName}}.{{.Name}}Func: method is nil but {{$mock.InterfaceName}}.{{.Name}} was just called") + } + {{- end}} + callInfo := {{$mock.MockName}}{{.Name}}Calls + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] + {{- 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}} + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] + {{- end -}} + ) {{.Name}}Calls() []{{$mock.MockName}}{{.Name}}Calls + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] + {{- end }} { + var calls []{{$mock.MockName}}{{.Name}}Calls + {{- if $mock.TypeParams -}} + [{{- range $index, $param := $mock.TypeParams}} + {{- if $index}}, {{end}}{{$param.Name | Exported}} + {{- end -}}] + {{- end }} + mock.lock{{.Name}}.RLock() + calls = mock.calls.{{.Name}} + 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 of functions */}} +{{end -}} \ No newline at end of file diff --git a/main.go b/main.go index 89adb3d..e2a1fec 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "path/filepath" @@ -109,5 +108,5 @@ func run(flags userFlags) error { return err } - return ioutil.WriteFile(flags.outFile, buf.Bytes(), 0o600) + return os.WriteFile(flags.outFile, buf.Bytes(), 0o600) } diff --git a/pkg/moq/moq_test.go b/pkg/moq/moq_test.go index 2813238..d0e1a18 100644 --- a/pkg/moq/moq_test.go +++ b/pkg/moq/moq_test.go @@ -303,6 +303,12 @@ func TestMockGolden(t *testing.T) { interfaces []string goldenFile string }{ + { + name: "PersonStore", + cfg: Config{SrcDir: "testpackages/example"}, + interfaces: []string{"PersonStore"}, + goldenFile: filepath.Join("testpackages/example", "example.golden.go"), + }, { // Tests to ensure slice return data type works as expected. // See https://github.com/matryer/moq/issues/124 @@ -420,7 +426,6 @@ func TestMockGolden(t *testing.T) { t.Errorf("m.Mock: %s", err) return } - if err := matchGoldenFile(tc.goldenFile, buf.Bytes()); err != nil { t.Errorf("check golden file: %s", err) } diff --git a/pkg/moq/testpackages/anonimport/iface_moq.golden.go b/pkg/moq/testpackages/anonimport/iface_moq.golden.go index fc06dcd..986b2e4 100644 --- a/pkg/moq/testpackages/anonimport/iface_moq.golden.go +++ b/pkg/moq/testpackages/anonimport/iface_moq.golden.go @@ -27,6 +27,7 @@ var _ Example = &ExampleMock{} // // and then make assertions. // // } + type ExampleMock struct { // CtxFunc mocks the Ctx method. CtxFunc func(ctx context.Context) @@ -34,22 +35,23 @@ type ExampleMock struct { // calls tracks calls to the methods. calls struct { // Ctx holds details about calls to the Ctx method. - Ctx []struct { - // Ctx is the ctx argument value. - Ctx context.Context - } + Ctx []ExampleMockCtxCalls } lockCtx sync.RWMutex } +// ExampleMockCtxCalls holds details about calls to the Ctx method. +type ExampleMockCtxCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context +} + // Ctx calls CtxFunc. func (mock *ExampleMock) Ctx(ctx context.Context) { if mock.CtxFunc == nil { panic("ExampleMock.CtxFunc: method is nil but Example.Ctx was just called") } - callInfo := struct { - Ctx context.Context - }{ + callInfo := ExampleMockCtxCalls{ Ctx: ctx, } mock.lockCtx.Lock() @@ -62,12 +64,8 @@ func (mock *ExampleMock) Ctx(ctx context.Context) { // Check the length with: // // len(mockedExample.CtxCalls()) -func (mock *ExampleMock) CtxCalls() []struct { - Ctx context.Context -} { - var calls []struct { - Ctx context.Context - } +func (mock *ExampleMock) CtxCalls() []ExampleMockCtxCalls { + var calls []ExampleMockCtxCalls mock.lockCtx.RLock() calls = mock.calls.Ctx mock.lockCtx.RUnlock() diff --git a/pkg/moq/testpackages/blankid/swallower.golden.go b/pkg/moq/testpackages/blankid/swallower.golden.go index d532701..786e6b9 100644 --- a/pkg/moq/testpackages/blankid/swallower.golden.go +++ b/pkg/moq/testpackages/blankid/swallower.golden.go @@ -26,6 +26,7 @@ var _ Swallower = &SwallowerMock{} // // and then make assertions. // // } + type SwallowerMock struct { // SwallowFunc mocks the Swallow method. SwallowFunc func(s string) @@ -33,22 +34,23 @@ type SwallowerMock struct { // calls tracks calls to the methods. calls struct { // Swallow holds details about calls to the Swallow method. - Swallow []struct { - // S is the s argument value. - S string - } + Swallow []SwallowerMockSwallowCalls } lockSwallow sync.RWMutex } +// SwallowerMockSwallowCalls holds details about calls to the Swallow method. +type SwallowerMockSwallowCalls struct { + // S is the s argument value. + S string +} + // Swallow calls SwallowFunc. func (mock *SwallowerMock) Swallow(s string) { if mock.SwallowFunc == nil { panic("SwallowerMock.SwallowFunc: method is nil but Swallower.Swallow was just called") } - callInfo := struct { - S string - }{ + callInfo := SwallowerMockSwallowCalls{ S: s, } mock.lockSwallow.Lock() @@ -61,12 +63,8 @@ func (mock *SwallowerMock) Swallow(s string) { // Check the length with: // // len(mockedSwallower.SwallowCalls()) -func (mock *SwallowerMock) SwallowCalls() []struct { - S string -} { - var calls []struct { - S string - } +func (mock *SwallowerMock) SwallowCalls() []SwallowerMockSwallowCalls { + var calls []SwallowerMockSwallowCalls mock.lockSwallow.RLock() calls = mock.calls.Swallow mock.lockSwallow.RUnlock() diff --git a/pkg/moq/testpackages/channels/queuer_moq.golden.go b/pkg/moq/testpackages/channels/queuer_moq.golden.go index 96c3a54..254a504 100644 --- a/pkg/moq/testpackages/channels/queuer_moq.golden.go +++ b/pkg/moq/testpackages/channels/queuer_moq.golden.go @@ -29,6 +29,7 @@ var _ Queuer = &QueuerMock{} // // and then make assertions. // // } + type QueuerMock struct { // SubFunc mocks the Sub method. SubFunc func(topic string) (<-chan Queue, error) @@ -39,25 +40,29 @@ type QueuerMock struct { // calls tracks calls to the methods. calls struct { // Sub holds details about calls to the Sub method. - Sub []struct { - // Topic is the topic argument value. - Topic string - } + Sub []QueuerMockSubCalls // Unsub holds details about calls to the Unsub method. - Unsub []struct { - // Topic is the topic argument value. - Topic string - } + Unsub []QueuerMockUnsubCalls } lockSub sync.RWMutex lockUnsub sync.RWMutex } +// QueuerMockSubCalls holds details about calls to the Sub method. +type QueuerMockSubCalls struct { + // Topic is the topic argument value. + Topic string +} + +// QueuerMockUnsubCalls holds details about calls to the Unsub method. +type QueuerMockUnsubCalls struct { + // Topic is the topic argument value. + Topic string +} + // Sub calls SubFunc. func (mock *QueuerMock) Sub(topic string) (<-chan Queue, error) { - callInfo := struct { - Topic string - }{ + callInfo := QueuerMockSubCalls{ Topic: topic, } mock.lockSub.Lock() @@ -77,12 +82,8 @@ func (mock *QueuerMock) Sub(topic string) (<-chan Queue, error) { // Check the length with: // // len(mockedQueuer.SubCalls()) -func (mock *QueuerMock) SubCalls() []struct { - Topic string -} { - var calls []struct { - Topic string - } +func (mock *QueuerMock) SubCalls() []QueuerMockSubCalls { + var calls []QueuerMockSubCalls mock.lockSub.RLock() calls = mock.calls.Sub mock.lockSub.RUnlock() @@ -91,9 +92,7 @@ func (mock *QueuerMock) SubCalls() []struct { // Unsub calls UnsubFunc. func (mock *QueuerMock) Unsub(topic string) { - callInfo := struct { - Topic string - }{ + callInfo := QueuerMockUnsubCalls{ Topic: topic, } mock.lockUnsub.Lock() @@ -109,12 +108,8 @@ func (mock *QueuerMock) Unsub(topic string) { // Check the length with: // // len(mockedQueuer.UnsubCalls()) -func (mock *QueuerMock) UnsubCalls() []struct { - Topic string -} { - var calls []struct { - Topic string - } +func (mock *QueuerMock) UnsubCalls() []QueuerMockUnsubCalls { + var calls []QueuerMockUnsubCalls mock.lockUnsub.RLock() calls = mock.calls.Unsub mock.lockUnsub.RUnlock() diff --git a/pkg/moq/testpackages/example/example.golden.go b/pkg/moq/testpackages/example/example.golden.go new file mode 100644 index 0000000..1e77dc7 --- /dev/null +++ b/pkg/moq/testpackages/example/example.golden.go @@ -0,0 +1,164 @@ +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq + +package example + +import ( + "context" + "sync" +) + +// Ensure, that PersonStoreMock does implement PersonStore. +// If this is not the case, regenerate this file with moq. +var _ PersonStore = &PersonStoreMock{} + +// PersonStoreMock is a mock implementation of PersonStore. +// +// func TestSomethingThatUsesPersonStore(t *testing.T) { +// +// // make and configure a mocked PersonStore +// mockedPersonStore := &PersonStoreMock{ +// ClearCacheFunc: func(id string) { +// panic("mock out the ClearCache method") +// }, +// CreateFunc: func(ctx context.Context, person *Person, confirm bool) error { +// panic("mock out the Create method") +// }, +// GetFunc: func(ctx context.Context, id string) (*Person, error) { +// panic("mock out the Get method") +// }, +// } +// +// // use mockedPersonStore in code that requires PersonStore +// // and then make assertions. +// +// } + +type PersonStoreMock struct { + // ClearCacheFunc mocks the ClearCache method. + ClearCacheFunc func(id string) + + // CreateFunc mocks the Create method. + CreateFunc func(ctx context.Context, person *Person, confirm bool) error + + // GetFunc mocks the Get method. + GetFunc func(ctx context.Context, id string) (*Person, error) + + // calls tracks calls to the methods. + calls struct { + // ClearCache holds details about calls to the ClearCache method. + ClearCache []PersonStoreMockClearCacheCalls + // Create holds details about calls to the Create method. + Create []PersonStoreMockCreateCalls + // Get holds details about calls to the Get method. + Get []PersonStoreMockGetCalls + } + lockClearCache sync.RWMutex + lockCreate sync.RWMutex + lockGet sync.RWMutex +} + +// PersonStoreMockClearCacheCalls holds details about calls to the ClearCache method. +type PersonStoreMockClearCacheCalls struct { + // ID is the id argument value. + ID string +} + +// PersonStoreMockCreateCalls holds details about calls to the Create method. +type PersonStoreMockCreateCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Person is the person argument value. + Person *Person + // Confirm is the confirm argument value. + Confirm bool +} + +// PersonStoreMockGetCalls holds details about calls to the Get method. +type PersonStoreMockGetCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID string +} + +// ClearCache calls ClearCacheFunc. +func (mock *PersonStoreMock) ClearCache(id string) { + if mock.ClearCacheFunc == nil { + panic("PersonStoreMock.ClearCacheFunc: method is nil but PersonStore.ClearCache was just called") + } + callInfo := PersonStoreMockClearCacheCalls{ + ID: id, + } + mock.lockClearCache.Lock() + mock.calls.ClearCache = append(mock.calls.ClearCache, callInfo) + mock.lockClearCache.Unlock() + mock.ClearCacheFunc(id) +} + +// ClearCacheCalls gets all the calls that were made to ClearCache. +// Check the length with: +// +// len(mockedPersonStore.ClearCacheCalls()) +func (mock *PersonStoreMock) ClearCacheCalls() []PersonStoreMockClearCacheCalls { + var calls []PersonStoreMockClearCacheCalls + mock.lockClearCache.RLock() + calls = mock.calls.ClearCache + mock.lockClearCache.RUnlock() + return calls +} + +// Create calls CreateFunc. +func (mock *PersonStoreMock) Create(ctx context.Context, person *Person, confirm bool) error { + if mock.CreateFunc == nil { + panic("PersonStoreMock.CreateFunc: method is nil but PersonStore.Create was just called") + } + callInfo := PersonStoreMockCreateCalls{ + Ctx: ctx, + Person: person, + Confirm: confirm, + } + mock.lockCreate.Lock() + mock.calls.Create = append(mock.calls.Create, callInfo) + mock.lockCreate.Unlock() + return mock.CreateFunc(ctx, person, confirm) +} + +// CreateCalls gets all the calls that were made to Create. +// Check the length with: +// +// len(mockedPersonStore.CreateCalls()) +func (mock *PersonStoreMock) CreateCalls() []PersonStoreMockCreateCalls { + var calls []PersonStoreMockCreateCalls + mock.lockCreate.RLock() + calls = mock.calls.Create + mock.lockCreate.RUnlock() + return calls +} + +// Get calls GetFunc. +func (mock *PersonStoreMock) Get(ctx context.Context, id string) (*Person, error) { + if mock.GetFunc == nil { + panic("PersonStoreMock.GetFunc: method is nil but PersonStore.Get was just called") + } + callInfo := PersonStoreMockGetCalls{ + Ctx: ctx, + ID: id, + } + mock.lockGet.Lock() + mock.calls.Get = append(mock.calls.Get, callInfo) + mock.lockGet.Unlock() + return mock.GetFunc(ctx, id) +} + +// GetCalls gets all the calls that were made to Get. +// Check the length with: +// +// len(mockedPersonStore.GetCalls()) +func (mock *PersonStoreMock) GetCalls() []PersonStoreMockGetCalls { + var calls []PersonStoreMockGetCalls + mock.lockGet.RLock() + calls = mock.calls.Get + mock.lockGet.RUnlock() + return calls +} diff --git a/pkg/moq/testpackages/genericreturn/genericreturn.golden.go b/pkg/moq/testpackages/genericreturn/genericreturn.golden.go index 38d27c8..689364c 100644 --- a/pkg/moq/testpackages/genericreturn/genericreturn.golden.go +++ b/pkg/moq/testpackages/genericreturn/genericreturn.golden.go @@ -27,6 +27,7 @@ var _ IFooBar = &IFooBarMock{} // // and then make assertions. // // } + type IFooBarMock struct { // FoobarFunc mocks the Foobar method. FoobarFunc func() GenericBar[otherpackage.Foo] @@ -34,19 +35,21 @@ type IFooBarMock struct { // calls tracks calls to the methods. calls struct { // Foobar holds details about calls to the Foobar method. - Foobar []struct { - } + Foobar []IFooBarMockFoobarCalls } lockFoobar sync.RWMutex } +// IFooBarMockFoobarCalls holds details about calls to the Foobar method. +type IFooBarMockFoobarCalls struct { +} + // Foobar calls FoobarFunc. func (mock *IFooBarMock) Foobar() GenericBar[otherpackage.Foo] { if mock.FoobarFunc == nil { panic("IFooBarMock.FoobarFunc: method is nil but IFooBar.Foobar was just called") } - callInfo := struct { - }{} + callInfo := IFooBarMockFoobarCalls{} mock.lockFoobar.Lock() mock.calls.Foobar = append(mock.calls.Foobar, callInfo) mock.lockFoobar.Unlock() @@ -57,10 +60,8 @@ func (mock *IFooBarMock) Foobar() GenericBar[otherpackage.Foo] { // Check the length with: // // len(mockedIFooBar.FoobarCalls()) -func (mock *IFooBarMock) FoobarCalls() []struct { -} { - var calls []struct { - } +func (mock *IFooBarMock) FoobarCalls() []IFooBarMockFoobarCalls { + var calls []IFooBarMockFoobarCalls mock.lockFoobar.RLock() calls = mock.calls.Foobar mock.lockFoobar.RUnlock() diff --git a/pkg/moq/testpackages/generics/generics_moq.golden.go b/pkg/moq/testpackages/generics/generics_moq.golden.go index ab4b75c..a15dd3b 100644 --- a/pkg/moq/testpackages/generics/generics_moq.golden.go +++ b/pkg/moq/testpackages/generics/generics_moq.golden.go @@ -30,6 +30,7 @@ var _ GenericStore1[Key1, any] = &GenericStore1Mock[Key1, any]{} // // and then make assertions. // // } + type GenericStore1Mock[T Key1, S any] struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, id T, value S) error @@ -40,36 +41,38 @@ type GenericStore1Mock[T Key1, S any] struct { // calls tracks calls to the methods. calls struct { // Create holds details about calls to the Create method. - Create []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID T - // Value is the value argument value. - Value S - } + Create []GenericStore1MockCreateCalls[T, S] // Get holds details about calls to the Get method. - Get []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID T - } + Get []GenericStore1MockGetCalls[T, S] } lockCreate sync.RWMutex lockGet sync.RWMutex } +// GenericStore1MockCreateCalls holds details about calls to the Create method. +type GenericStore1MockCreateCalls[T Key1, S any] struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID T + // Value is the value argument value. + Value S +} + +// GenericStore1MockGetCalls holds details about calls to the Get method. +type GenericStore1MockGetCalls[T Key1, S any] struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID T +} + // Create calls CreateFunc. func (mock *GenericStore1Mock[T, S]) Create(ctx context.Context, id T, value S) error { if mock.CreateFunc == nil { panic("GenericStore1Mock.CreateFunc: method is nil but GenericStore1.Create was just called") } - callInfo := struct { - Ctx context.Context - ID T - Value S - }{ + callInfo := GenericStore1MockCreateCalls[T, S]{ Ctx: ctx, ID: id, Value: value, @@ -84,16 +87,8 @@ func (mock *GenericStore1Mock[T, S]) Create(ctx context.Context, id T, value S) // Check the length with: // // len(mockedGenericStore1.CreateCalls()) -func (mock *GenericStore1Mock[T, S]) CreateCalls() []struct { - Ctx context.Context - ID T - Value S -} { - var calls []struct { - Ctx context.Context - ID T - Value S - } +func (mock *GenericStore1Mock[T, S]) CreateCalls() []GenericStore1MockCreateCalls[T, S] { + var calls []GenericStore1MockCreateCalls[T, S] mock.lockCreate.RLock() calls = mock.calls.Create mock.lockCreate.RUnlock() @@ -105,10 +100,7 @@ func (mock *GenericStore1Mock[T, S]) Get(ctx context.Context, id T) (S, error) { if mock.GetFunc == nil { panic("GenericStore1Mock.GetFunc: method is nil but GenericStore1.Get was just called") } - callInfo := struct { - Ctx context.Context - ID T - }{ + callInfo := GenericStore1MockGetCalls[T, S]{ Ctx: ctx, ID: id, } @@ -122,14 +114,8 @@ func (mock *GenericStore1Mock[T, S]) Get(ctx context.Context, id T) (S, error) { // Check the length with: // // len(mockedGenericStore1.GetCalls()) -func (mock *GenericStore1Mock[T, S]) GetCalls() []struct { - Ctx context.Context - ID T -} { - var calls []struct { - Ctx context.Context - ID T - } +func (mock *GenericStore1Mock[T, S]) GetCalls() []GenericStore1MockGetCalls[T, S] { + var calls []GenericStore1MockGetCalls[T, S] mock.lockGet.RLock() calls = mock.calls.Get mock.lockGet.RUnlock() @@ -158,6 +144,7 @@ var _ GenericStore2[[]byte, any] = &GenericStore2Mock[[]byte, any]{} // // and then make assertions. // // } + type GenericStore2Mock[T Key2, S any] struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, id T, value S) error @@ -168,36 +155,38 @@ type GenericStore2Mock[T Key2, S any] struct { // calls tracks calls to the methods. calls struct { // Create holds details about calls to the Create method. - Create []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID T - // Value is the value argument value. - Value S - } + Create []GenericStore2MockCreateCalls[T, S] // Get holds details about calls to the Get method. - Get []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID T - } + Get []GenericStore2MockGetCalls[T, S] } lockCreate sync.RWMutex lockGet sync.RWMutex } +// GenericStore2MockCreateCalls holds details about calls to the Create method. +type GenericStore2MockCreateCalls[T Key2, S any] struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID T + // Value is the value argument value. + Value S +} + +// GenericStore2MockGetCalls holds details about calls to the Get method. +type GenericStore2MockGetCalls[T Key2, S any] struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID T +} + // Create calls CreateFunc. func (mock *GenericStore2Mock[T, S]) Create(ctx context.Context, id T, value S) error { if mock.CreateFunc == nil { panic("GenericStore2Mock.CreateFunc: method is nil but GenericStore2.Create was just called") } - callInfo := struct { - Ctx context.Context - ID T - Value S - }{ + callInfo := GenericStore2MockCreateCalls[T, S]{ Ctx: ctx, ID: id, Value: value, @@ -212,16 +201,8 @@ func (mock *GenericStore2Mock[T, S]) Create(ctx context.Context, id T, value S) // Check the length with: // // len(mockedGenericStore2.CreateCalls()) -func (mock *GenericStore2Mock[T, S]) CreateCalls() []struct { - Ctx context.Context - ID T - Value S -} { - var calls []struct { - Ctx context.Context - ID T - Value S - } +func (mock *GenericStore2Mock[T, S]) CreateCalls() []GenericStore2MockCreateCalls[T, S] { + var calls []GenericStore2MockCreateCalls[T, S] mock.lockCreate.RLock() calls = mock.calls.Create mock.lockCreate.RUnlock() @@ -233,10 +214,7 @@ func (mock *GenericStore2Mock[T, S]) Get(ctx context.Context, id T) (S, error) { if mock.GetFunc == nil { panic("GenericStore2Mock.GetFunc: method is nil but GenericStore2.Get was just called") } - callInfo := struct { - Ctx context.Context - ID T - }{ + callInfo := GenericStore2MockGetCalls[T, S]{ Ctx: ctx, ID: id, } @@ -250,14 +228,8 @@ func (mock *GenericStore2Mock[T, S]) Get(ctx context.Context, id T) (S, error) { // Check the length with: // // len(mockedGenericStore2.GetCalls()) -func (mock *GenericStore2Mock[T, S]) GetCalls() []struct { - Ctx context.Context - ID T -} { - var calls []struct { - Ctx context.Context - ID T - } +func (mock *GenericStore2Mock[T, S]) GetCalls() []GenericStore2MockGetCalls[T, S] { + var calls []GenericStore2MockGetCalls[T, S] mock.lockGet.RLock() calls = mock.calls.Get mock.lockGet.RUnlock() @@ -286,6 +258,7 @@ var _ AliasStore = &AliasStoreMock{} // // and then make assertions. // // } + type AliasStoreMock struct { // CreateFunc mocks the Create method. CreateFunc func(ctx context.Context, id KeyImpl, value bool) error @@ -296,36 +269,38 @@ type AliasStoreMock struct { // calls tracks calls to the methods. calls struct { // Create holds details about calls to the Create method. - Create []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID KeyImpl - // Value is the value argument value. - Value bool - } + Create []AliasStoreMockCreateCalls // Get holds details about calls to the Get method. - Get []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID KeyImpl - } + Get []AliasStoreMockGetCalls } lockCreate sync.RWMutex lockGet sync.RWMutex } +// AliasStoreMockCreateCalls holds details about calls to the Create method. +type AliasStoreMockCreateCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID KeyImpl + // Value is the value argument value. + Value bool +} + +// AliasStoreMockGetCalls holds details about calls to the Get method. +type AliasStoreMockGetCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID KeyImpl +} + // Create calls CreateFunc. func (mock *AliasStoreMock) Create(ctx context.Context, id KeyImpl, value bool) error { if mock.CreateFunc == nil { panic("AliasStoreMock.CreateFunc: method is nil but AliasStore.Create was just called") } - callInfo := struct { - Ctx context.Context - ID KeyImpl - Value bool - }{ + callInfo := AliasStoreMockCreateCalls{ Ctx: ctx, ID: id, Value: value, @@ -340,16 +315,8 @@ func (mock *AliasStoreMock) Create(ctx context.Context, id KeyImpl, value bool) // Check the length with: // // len(mockedAliasStore.CreateCalls()) -func (mock *AliasStoreMock) CreateCalls() []struct { - Ctx context.Context - ID KeyImpl - Value bool -} { - var calls []struct { - Ctx context.Context - ID KeyImpl - Value bool - } +func (mock *AliasStoreMock) CreateCalls() []AliasStoreMockCreateCalls { + var calls []AliasStoreMockCreateCalls mock.lockCreate.RLock() calls = mock.calls.Create mock.lockCreate.RUnlock() @@ -361,10 +328,7 @@ func (mock *AliasStoreMock) Get(ctx context.Context, id KeyImpl) (bool, error) { if mock.GetFunc == nil { panic("AliasStoreMock.GetFunc: method is nil but AliasStore.Get was just called") } - callInfo := struct { - Ctx context.Context - ID KeyImpl - }{ + callInfo := AliasStoreMockGetCalls{ Ctx: ctx, ID: id, } @@ -378,14 +342,8 @@ func (mock *AliasStoreMock) Get(ctx context.Context, id KeyImpl) (bool, error) { // Check the length with: // // len(mockedAliasStore.GetCalls()) -func (mock *AliasStoreMock) GetCalls() []struct { - Ctx context.Context - ID KeyImpl -} { - var calls []struct { - Ctx context.Context - ID KeyImpl - } +func (mock *AliasStoreMock) GetCalls() []AliasStoreMockGetCalls { + var calls []AliasStoreMockGetCalls mock.lockGet.RLock() calls = mock.calls.Get mock.lockGet.RUnlock() diff --git a/pkg/moq/testpackages/genparamname/iface_moq.golden.go b/pkg/moq/testpackages/genparamname/iface_moq.golden.go index 540f035..59bca43 100644 --- a/pkg/moq/testpackages/genparamname/iface_moq.golden.go +++ b/pkg/moq/testpackages/genparamname/iface_moq.golden.go @@ -34,6 +34,7 @@ var _ Interface = &InterfaceMock{} // // and then make assertions. // // } + type InterfaceMock struct { // MethodFunc mocks the Method method. MethodFunc func(myTypeMoqParam *myType, numbers [3]json.Number, bytes []byte, nullStringToReader map[sql.NullString]io.Reader, fn func(conn net.Conn), goMoqParam Go, bufferPoolCh chan *httputil.BufferPool, val struct{ URL *url.URL }, ifaceVal interface { @@ -44,33 +45,36 @@ type InterfaceMock struct { // calls tracks calls to the methods. calls struct { // Method holds details about calls to the Method method. - Method []struct { - // MyTypeMoqParam is the myTypeMoqParam argument value. - MyTypeMoqParam *myType - // Numbers is the numbers argument value. - Numbers [3]json.Number - // Bytes is the bytes argument value. - Bytes []byte - // NullStringToReader is the nullStringToReader argument value. - NullStringToReader map[sql.NullString]io.Reader - // Fn is the fn argument value. - Fn func(conn net.Conn) - // GoMoqParam is the goMoqParam argument value. - GoMoqParam Go - // BufferPoolCh is the bufferPoolCh argument value. - BufferPoolCh chan *httputil.BufferPool - // Val is the val argument value. - Val struct{ URL *url.URL } - // IfaceVal is the ifaceVal argument value. - IfaceVal interface { - CookieJar() http.CookieJar - fmt.Stringer - } - } + Method []InterfaceMockMethodCalls } lockMethod sync.RWMutex } +// InterfaceMockMethodCalls holds details about calls to the Method method. +type InterfaceMockMethodCalls struct { + // MyTypeMoqParam is the myTypeMoqParam argument value. + MyTypeMoqParam *myType + // Numbers is the numbers argument value. + Numbers [3]json.Number + // Bytes is the bytes argument value. + Bytes []byte + // NullStringToReader is the nullStringToReader argument value. + NullStringToReader map[sql.NullString]io.Reader + // Fn is the fn argument value. + Fn func(conn net.Conn) + // GoMoqParam is the goMoqParam argument value. + GoMoqParam Go + // BufferPoolCh is the bufferPoolCh argument value. + BufferPoolCh chan *httputil.BufferPool + // Val is the val argument value. + Val struct{ URL *url.URL } + // IfaceVal is the ifaceVal argument value. + IfaceVal interface { + CookieJar() http.CookieJar + fmt.Stringer + } +} + // Method calls MethodFunc. func (mock *InterfaceMock) Method(myTypeMoqParam *myType, numbers [3]json.Number, bytes []byte, nullStringToReader map[sql.NullString]io.Reader, fn func(conn net.Conn), goMoqParam Go, bufferPoolCh chan *httputil.BufferPool, val struct{ URL *url.URL }, ifaceVal interface { CookieJar() http.CookieJar @@ -79,20 +83,7 @@ func (mock *InterfaceMock) Method(myTypeMoqParam *myType, numbers [3]json.Number if mock.MethodFunc == nil { panic("InterfaceMock.MethodFunc: method is nil but Interface.Method was just called") } - callInfo := struct { - MyTypeMoqParam *myType - Numbers [3]json.Number - Bytes []byte - NullStringToReader map[sql.NullString]io.Reader - Fn func(conn net.Conn) - GoMoqParam Go - BufferPoolCh chan *httputil.BufferPool - Val struct{ URL *url.URL } - IfaceVal interface { - CookieJar() http.CookieJar - fmt.Stringer - } - }{ + callInfo := InterfaceMockMethodCalls{ MyTypeMoqParam: myTypeMoqParam, Numbers: numbers, Bytes: bytes, @@ -113,34 +104,8 @@ func (mock *InterfaceMock) Method(myTypeMoqParam *myType, numbers [3]json.Number // Check the length with: // // len(mockedInterface.MethodCalls()) -func (mock *InterfaceMock) MethodCalls() []struct { - MyTypeMoqParam *myType - Numbers [3]json.Number - Bytes []byte - NullStringToReader map[sql.NullString]io.Reader - Fn func(conn net.Conn) - GoMoqParam Go - BufferPoolCh chan *httputil.BufferPool - Val struct{ URL *url.URL } - IfaceVal interface { - CookieJar() http.CookieJar - fmt.Stringer - } -} { - var calls []struct { - MyTypeMoqParam *myType - Numbers [3]json.Number - Bytes []byte - NullStringToReader map[sql.NullString]io.Reader - Fn func(conn net.Conn) - GoMoqParam Go - BufferPoolCh chan *httputil.BufferPool - Val struct{ URL *url.URL } - IfaceVal interface { - CookieJar() http.CookieJar - fmt.Stringer - } - } +func (mock *InterfaceMock) MethodCalls() []InterfaceMockMethodCalls { + var calls []InterfaceMockMethodCalls mock.lockMethod.RLock() calls = mock.calls.Method mock.lockMethod.RUnlock() diff --git a/pkg/moq/testpackages/importalias/middleman_moq.golden.go b/pkg/moq/testpackages/importalias/middleman_moq.golden.go index 63aa7ed..ba4b96b 100644 --- a/pkg/moq/testpackages/importalias/middleman_moq.golden.go +++ b/pkg/moq/testpackages/importalias/middleman_moq.golden.go @@ -28,6 +28,7 @@ var _ MiddleMan = &MiddleManMock{} // // and then make assertions. // // } + type MiddleManMock struct { // ConnectFunc mocks the Connect method. ConnectFunc func(src srcclient.Client, tgt tgtclient.Client) @@ -35,25 +36,25 @@ type MiddleManMock struct { // calls tracks calls to the methods. calls struct { // Connect holds details about calls to the Connect method. - Connect []struct { - // Src is the src argument value. - Src srcclient.Client - // Tgt is the tgt argument value. - Tgt tgtclient.Client - } + Connect []MiddleManMockConnectCalls } lockConnect sync.RWMutex } +// MiddleManMockConnectCalls holds details about calls to the Connect method. +type MiddleManMockConnectCalls struct { + // Src is the src argument value. + Src srcclient.Client + // Tgt is the tgt argument value. + Tgt tgtclient.Client +} + // Connect calls ConnectFunc. func (mock *MiddleManMock) Connect(src srcclient.Client, tgt tgtclient.Client) { if mock.ConnectFunc == nil { panic("MiddleManMock.ConnectFunc: method is nil but MiddleMan.Connect was just called") } - callInfo := struct { - Src srcclient.Client - Tgt tgtclient.Client - }{ + callInfo := MiddleManMockConnectCalls{ Src: src, Tgt: tgt, } @@ -67,14 +68,8 @@ func (mock *MiddleManMock) Connect(src srcclient.Client, tgt tgtclient.Client) { // Check the length with: // // len(mockedMiddleMan.ConnectCalls()) -func (mock *MiddleManMock) ConnectCalls() []struct { - Src srcclient.Client - Tgt tgtclient.Client -} { - var calls []struct { - Src srcclient.Client - Tgt tgtclient.Client - } +func (mock *MiddleManMock) ConnectCalls() []MiddleManMockConnectCalls { + var calls []MiddleManMockConnectCalls mock.lockConnect.RLock() calls = mock.calls.Connect mock.lockConnect.RUnlock() diff --git a/pkg/moq/testpackages/imports/two/gofmt.golden.go b/pkg/moq/testpackages/imports/two/gofmt.golden.go index f2be081..518227a 100644 --- a/pkg/moq/testpackages/imports/two/gofmt.golden.go +++ b/pkg/moq/testpackages/imports/two/gofmt.golden.go @@ -30,6 +30,7 @@ var _ DoSomething = &gofmtMock{} // // and then make assertions. // // } + type gofmtMock struct { // AnotherFunc mocks the Another method. AnotherFunc func(thing one.Thing) error @@ -40,28 +41,32 @@ type gofmtMock struct { // calls tracks calls to the methods. calls struct { // Another holds details about calls to the Another method. - Another []struct { - // Thing is the thing argument value. - Thing one.Thing - } + Another []gofmtMockAnotherCalls // Do holds details about calls to the Do method. - Do []struct { - // Thing is the thing argument value. - Thing one.Thing - } + Do []gofmtMockDoCalls } lockAnother sync.RWMutex lockDo sync.RWMutex } +// gofmtMockAnotherCalls holds details about calls to the Another method. +type gofmtMockAnotherCalls struct { + // Thing is the thing argument value. + Thing one.Thing +} + +// gofmtMockDoCalls holds details about calls to the Do method. +type gofmtMockDoCalls struct { + // Thing is the thing argument value. + Thing one.Thing +} + // Another calls AnotherFunc. func (mock *gofmtMock) Another(thing one.Thing) error { if mock.AnotherFunc == nil { panic("gofmtMock.AnotherFunc: method is nil but DoSomething.Another was just called") } - callInfo := struct { - Thing one.Thing - }{ + callInfo := gofmtMockAnotherCalls{ Thing: thing, } mock.lockAnother.Lock() @@ -74,12 +79,8 @@ func (mock *gofmtMock) Another(thing one.Thing) error { // Check the length with: // // len(mockedDoSomething.AnotherCalls()) -func (mock *gofmtMock) AnotherCalls() []struct { - Thing one.Thing -} { - var calls []struct { - Thing one.Thing - } +func (mock *gofmtMock) AnotherCalls() []gofmtMockAnotherCalls { + var calls []gofmtMockAnotherCalls mock.lockAnother.RLock() calls = mock.calls.Another mock.lockAnother.RUnlock() @@ -91,9 +92,7 @@ func (mock *gofmtMock) Do(thing one.Thing) error { if mock.DoFunc == nil { panic("gofmtMock.DoFunc: method is nil but DoSomething.Do was just called") } - callInfo := struct { - Thing one.Thing - }{ + callInfo := gofmtMockDoCalls{ Thing: thing, } mock.lockDo.Lock() @@ -106,12 +105,8 @@ func (mock *gofmtMock) Do(thing one.Thing) error { // Check the length with: // // len(mockedDoSomething.DoCalls()) -func (mock *gofmtMock) DoCalls() []struct { - Thing one.Thing -} { - var calls []struct { - Thing one.Thing - } +func (mock *gofmtMock) DoCalls() []gofmtMockDoCalls { + var calls []gofmtMockDoCalls mock.lockDo.RLock() calls = mock.calls.Do mock.lockDo.RUnlock() diff --git a/pkg/moq/testpackages/imports/two/goimports.golden.go b/pkg/moq/testpackages/imports/two/goimports.golden.go index 95ab1da..81d9601 100644 --- a/pkg/moq/testpackages/imports/two/goimports.golden.go +++ b/pkg/moq/testpackages/imports/two/goimports.golden.go @@ -31,6 +31,7 @@ var _ DoSomething = &goimportsMock{} // // and then make assertions. // // } + type goimportsMock struct { // AnotherFunc mocks the Another method. AnotherFunc func(thing one.Thing) error @@ -41,28 +42,32 @@ type goimportsMock struct { // calls tracks calls to the methods. calls struct { // Another holds details about calls to the Another method. - Another []struct { - // Thing is the thing argument value. - Thing one.Thing - } + Another []goimportsMockAnotherCalls // Do holds details about calls to the Do method. - Do []struct { - // Thing is the thing argument value. - Thing one.Thing - } + Do []goimportsMockDoCalls } lockAnother sync.RWMutex lockDo sync.RWMutex } +// goimportsMockAnotherCalls holds details about calls to the Another method. +type goimportsMockAnotherCalls struct { + // Thing is the thing argument value. + Thing one.Thing +} + +// goimportsMockDoCalls holds details about calls to the Do method. +type goimportsMockDoCalls struct { + // Thing is the thing argument value. + Thing one.Thing +} + // Another calls AnotherFunc. func (mock *goimportsMock) Another(thing one.Thing) error { if mock.AnotherFunc == nil { panic("goimportsMock.AnotherFunc: method is nil but DoSomething.Another was just called") } - callInfo := struct { - Thing one.Thing - }{ + callInfo := goimportsMockAnotherCalls{ Thing: thing, } mock.lockAnother.Lock() @@ -75,12 +80,8 @@ func (mock *goimportsMock) Another(thing one.Thing) error { // Check the length with: // // len(mockedDoSomething.AnotherCalls()) -func (mock *goimportsMock) AnotherCalls() []struct { - Thing one.Thing -} { - var calls []struct { - Thing one.Thing - } +func (mock *goimportsMock) AnotherCalls() []goimportsMockAnotherCalls { + var calls []goimportsMockAnotherCalls mock.lockAnother.RLock() calls = mock.calls.Another mock.lockAnother.RUnlock() @@ -92,9 +93,7 @@ func (mock *goimportsMock) Do(thing one.Thing) error { if mock.DoFunc == nil { panic("goimportsMock.DoFunc: method is nil but DoSomething.Do was just called") } - callInfo := struct { - Thing one.Thing - }{ + callInfo := goimportsMockDoCalls{ Thing: thing, } mock.lockDo.Lock() @@ -107,12 +106,8 @@ func (mock *goimportsMock) Do(thing one.Thing) error { // Check the length with: // // len(mockedDoSomething.DoCalls()) -func (mock *goimportsMock) DoCalls() []struct { - Thing one.Thing -} { - var calls []struct { - Thing one.Thing - } +func (mock *goimportsMock) DoCalls() []goimportsMockDoCalls { + var calls []goimportsMockDoCalls mock.lockDo.RLock() calls = mock.calls.Do mock.lockDo.RUnlock() diff --git a/pkg/moq/testpackages/imports/two/noop.golden.go b/pkg/moq/testpackages/imports/two/noop.golden.go index 0b9f26b..94ecdbc 100644 --- a/pkg/moq/testpackages/imports/two/noop.golden.go +++ b/pkg/moq/testpackages/imports/two/noop.golden.go @@ -9,111 +9,110 @@ import ( ) // Ensure, that noopMock does implement DoSomething. -// If this is not the case, regenerate this file with moq. -var _ DoSomething = &noopMock{} - -// noopMock is a mock implementation of DoSomething. -// -// func TestSomethingThatUsesDoSomething(t *testing.T) { -// -// // make and configure a mocked DoSomething -// mockedDoSomething := &noopMock{ -// AnotherFunc: func(thing one.Thing) error { -// panic("mock out the Another method") -// }, -// DoFunc: func(thing one.Thing) error { -// panic("mock out the Do method") -// }, -// } -// -// // use mockedDoSomething in code that requires DoSomething -// // and then make assertions. -// -// } -type noopMock struct { - // AnotherFunc mocks the Another method. - AnotherFunc func(thing one.Thing) error - - // DoFunc mocks the Do method. - DoFunc func(thing one.Thing) error + // If this is not the case, regenerate this file with moq. + var _ DoSomething = &noopMock{} + // noopMock is a mock implementation of DoSomething. + // + // func TestSomethingThatUsesDoSomething(t *testing.T) { + // + // // make and configure a mocked DoSomething + // mockedDoSomething := &noopMock{ + // AnotherFunc: func(thing one.Thing) error { + // panic("mock out the Another method") + // }, + // DoFunc: func(thing one.Thing) error { + // panic("mock out the Do method") + // }, + // } + // + // // use mockedDoSomething in code that requires DoSomething + // // and then make assertions. + // + // } + + type noopMock struct { + // AnotherFunc mocks the Another method. + AnotherFunc func(thing one.Thing) error + + // DoFunc mocks the Do method. + DoFunc func(thing one.Thing) error + // calls tracks calls to the methods. calls struct { // Another holds details about calls to the Another method. - Another []struct { + Another []noopMockAnotherCalls + // Do holds details about calls to the Do method. + Do []noopMockDoCalls + } + lockAnother sync.RWMutex + lockDo sync.RWMutex + } + + + // noopMockAnotherCalls holds details about calls to the Another method. + type noopMockAnotherCalls struct { // Thing is the thing argument value. Thing one.Thing } - // Do holds details about calls to the Do method. - Do []struct { + // noopMockDoCalls holds details about calls to the Do method. + type noopMockDoCalls struct { // Thing is the thing argument value. Thing one.Thing } - } - lockAnother sync.RWMutex - lockDo sync.RWMutex -} - -// Another calls AnotherFunc. -func (mock *noopMock) Another(thing one.Thing) error { - if mock.AnotherFunc == nil { - panic("noopMock.AnotherFunc: method is nil but DoSomething.Another was just called") - } - callInfo := struct { - Thing one.Thing - }{ - Thing: thing, - } - mock.lockAnother.Lock() - mock.calls.Another = append(mock.calls.Another, callInfo) - mock.lockAnother.Unlock() - return mock.AnotherFunc(thing) -} + -// AnotherCalls gets all the calls that were made to Another. -// Check the length with: -// -// len(mockedDoSomething.AnotherCalls()) -func (mock *noopMock) AnotherCalls() []struct { - Thing one.Thing - } { - var calls []struct { - Thing one.Thing - } - mock.lockAnother.RLock() - calls = mock.calls.Another - mock.lockAnother.RUnlock() - return calls -} + + + // Another calls AnotherFunc. + func (mock *noopMock) Another(thing one.Thing) error { + if mock.AnotherFunc == nil { + panic("noopMock.AnotherFunc: method is nil but DoSomething.Another was just called") + } + callInfo := noopMockAnotherCalls { + Thing: thing, + } + mock.lockAnother.Lock() + mock.calls.Another = append(mock.calls.Another, callInfo) + mock.lockAnother.Unlock() + return mock.AnotherFunc(thing) + } -// Do calls DoFunc. -func (mock *noopMock) Do(thing one.Thing) error { - if mock.DoFunc == nil { - panic("noopMock.DoFunc: method is nil but DoSomething.Do was just called") - } - callInfo := struct { - Thing one.Thing - }{ - Thing: thing, - } - mock.lockDo.Lock() - mock.calls.Do = append(mock.calls.Do, callInfo) - mock.lockDo.Unlock() - return mock.DoFunc(thing) -} + // AnotherCalls gets all the calls that were made to Another. + // Check the length with: + // + // len(mockedDoSomething.AnotherCalls()) + func (mock *noopMock) AnotherCalls() []noopMockAnotherCalls { + var calls []noopMockAnotherCalls + mock.lockAnother.RLock() + calls = mock.calls.Another + mock.lockAnother.RUnlock() + return calls + } + + // Do calls DoFunc. + func (mock *noopMock) Do(thing one.Thing) error { + if mock.DoFunc == nil { + panic("noopMock.DoFunc: method is nil but DoSomething.Do was just called") + } + callInfo := noopMockDoCalls { + Thing: thing, + } + mock.lockDo.Lock() + mock.calls.Do = append(mock.calls.Do, callInfo) + mock.lockDo.Unlock() + return mock.DoFunc(thing) + } -// DoCalls gets all the calls that were made to Do. -// Check the length with: -// -// len(mockedDoSomething.DoCalls()) -func (mock *noopMock) DoCalls() []struct { - Thing one.Thing - } { - var calls []struct { - Thing one.Thing - } - mock.lockDo.RLock() - calls = mock.calls.Do - mock.lockDo.RUnlock() - return calls -} + // DoCalls gets all the calls that were made to Do. + // Check the length with: + // + // len(mockedDoSomething.DoCalls()) + func (mock *noopMock) DoCalls() []noopMockDoCalls { + var calls []noopMockDoCalls + mock.lockDo.RLock() + calls = mock.calls.Do + mock.lockDo.RUnlock() + return calls + } + diff --git a/pkg/moq/testpackages/paramconflict/iface_moq.golden.go b/pkg/moq/testpackages/paramconflict/iface_moq.golden.go index b29a596..3799cb1 100644 --- a/pkg/moq/testpackages/paramconflict/iface_moq.golden.go +++ b/pkg/moq/testpackages/paramconflict/iface_moq.golden.go @@ -27,6 +27,7 @@ var _ Interface = &InterfaceMock{} // // and then make assertions. // // } + type InterfaceMock struct { // MethodFunc mocks the Method method. MethodFunc func(s1 string, b1 bool, s2 string, b2 bool, n1 int, n2 int32, n3 int64, f1 float32, f2 float64, timeMoqParam1 time.Time, timeMoqParam2 time.Time) @@ -34,52 +35,43 @@ type InterfaceMock struct { // calls tracks calls to the methods. calls struct { // Method holds details about calls to the Method method. - Method []struct { - // S1 is the s1 argument value. - S1 string - // B1 is the b1 argument value. - B1 bool - // S2 is the s2 argument value. - S2 string - // B2 is the b2 argument value. - B2 bool - // N1 is the n1 argument value. - N1 int - // N2 is the n2 argument value. - N2 int32 - // N3 is the n3 argument value. - N3 int64 - // F1 is the f1 argument value. - F1 float32 - // F2 is the f2 argument value. - F2 float64 - // TimeMoqParam1 is the timeMoqParam1 argument value. - TimeMoqParam1 time.Time - // TimeMoqParam2 is the timeMoqParam2 argument value. - TimeMoqParam2 time.Time - } + Method []InterfaceMockMethodCalls } lockMethod sync.RWMutex } +// InterfaceMockMethodCalls holds details about calls to the Method method. +type InterfaceMockMethodCalls struct { + // S1 is the s1 argument value. + S1 string + // B1 is the b1 argument value. + B1 bool + // S2 is the s2 argument value. + S2 string + // B2 is the b2 argument value. + B2 bool + // N1 is the n1 argument value. + N1 int + // N2 is the n2 argument value. + N2 int32 + // N3 is the n3 argument value. + N3 int64 + // F1 is the f1 argument value. + F1 float32 + // F2 is the f2 argument value. + F2 float64 + // TimeMoqParam1 is the timeMoqParam1 argument value. + TimeMoqParam1 time.Time + // TimeMoqParam2 is the timeMoqParam2 argument value. + TimeMoqParam2 time.Time +} + // Method calls MethodFunc. func (mock *InterfaceMock) Method(s1 string, b1 bool, s2 string, b2 bool, n1 int, n2 int32, n3 int64, f1 float32, f2 float64, timeMoqParam1 time.Time, timeMoqParam2 time.Time) { if mock.MethodFunc == nil { panic("InterfaceMock.MethodFunc: method is nil but Interface.Method was just called") } - callInfo := struct { - S1 string - B1 bool - S2 string - B2 bool - N1 int - N2 int32 - N3 int64 - F1 float32 - F2 float64 - TimeMoqParam1 time.Time - TimeMoqParam2 time.Time - }{ + callInfo := InterfaceMockMethodCalls{ S1: s1, B1: b1, S2: s2, @@ -102,32 +94,8 @@ func (mock *InterfaceMock) Method(s1 string, b1 bool, s2 string, b2 bool, n1 int // Check the length with: // // len(mockedInterface.MethodCalls()) -func (mock *InterfaceMock) MethodCalls() []struct { - S1 string - B1 bool - S2 string - B2 bool - N1 int - N2 int32 - N3 int64 - F1 float32 - F2 float64 - TimeMoqParam1 time.Time - TimeMoqParam2 time.Time -} { - var calls []struct { - S1 string - B1 bool - S2 string - B2 bool - N1 int - N2 int32 - N3 int64 - F1 float32 - F2 float64 - TimeMoqParam1 time.Time - TimeMoqParam2 time.Time - } +func (mock *InterfaceMock) MethodCalls() []InterfaceMockMethodCalls { + var calls []InterfaceMockMethodCalls mock.lockMethod.RLock() calls = mock.calls.Method mock.lockMethod.RUnlock() diff --git a/pkg/moq/testpackages/shadow/mock/thing_moq.golden.go b/pkg/moq/testpackages/shadow/mock/thing_moq.golden.go index 1f860d2..3cea847 100644 --- a/pkg/moq/testpackages/shadow/mock/thing_moq.golden.go +++ b/pkg/moq/testpackages/shadow/mock/thing_moq.golden.go @@ -28,6 +28,7 @@ var _ shadowhttp.Thing = &ThingMock{} // // and then make assertions. // // } + type ThingMock struct { // BlahFunc mocks the Blah method. BlahFunc func(w nethttp.ResponseWriter, r *nethttp.Request) @@ -35,25 +36,25 @@ type ThingMock struct { // calls tracks calls to the methods. calls struct { // Blah holds details about calls to the Blah method. - Blah []struct { - // W is the w argument value. - W nethttp.ResponseWriter - // R is the r argument value. - R *nethttp.Request - } + Blah []ThingMockBlahCalls } lockBlah sync.RWMutex } +// ThingMockBlahCalls holds details about calls to the Blah method. +type ThingMockBlahCalls struct { + // W is the w argument value. + W nethttp.ResponseWriter + // R is the r argument value. + R *nethttp.Request +} + // Blah calls BlahFunc. func (mock *ThingMock) Blah(w nethttp.ResponseWriter, r *nethttp.Request) { if mock.BlahFunc == nil { panic("ThingMock.BlahFunc: method is nil but Thing.Blah was just called") } - callInfo := struct { - W nethttp.ResponseWriter - R *nethttp.Request - }{ + callInfo := ThingMockBlahCalls{ W: w, R: r, } @@ -67,14 +68,8 @@ func (mock *ThingMock) Blah(w nethttp.ResponseWriter, r *nethttp.Request) { // Check the length with: // // len(mockedThing.BlahCalls()) -func (mock *ThingMock) BlahCalls() []struct { - W nethttp.ResponseWriter - R *nethttp.Request -} { - var calls []struct { - W nethttp.ResponseWriter - R *nethttp.Request - } +func (mock *ThingMock) BlahCalls() []ThingMockBlahCalls { + var calls []ThingMockBlahCalls mock.lockBlah.RLock() calls = mock.calls.Blah mock.lockBlah.RUnlock() diff --git a/pkg/moq/testpackages/shadow/shadower_moq.golden.go b/pkg/moq/testpackages/shadow/shadower_moq.golden.go index dbcda26..fefda2b 100644 --- a/pkg/moq/testpackages/shadow/shadower_moq.golden.go +++ b/pkg/moq/testpackages/shadow/shadower_moq.golden.go @@ -34,6 +34,7 @@ var _ Shadower = &ShadowerMock{} // // and then make assertions. // // } + type ShadowerMock struct { // ShadowFunc mocks the Shadow method. ShadowFunc func(ioMoqParam io.Reader) @@ -47,38 +48,45 @@ type ShadowerMock struct { // calls tracks calls to the methods. calls struct { // Shadow holds details about calls to the Shadow method. - Shadow []struct { - // IoMoqParam is the ioMoqParam argument value. - IoMoqParam io.Reader - } + Shadow []ShadowerMockShadowCalls // ShadowThree holds details about calls to the ShadowThree method. - ShadowThree []struct { - // HttpMoqParam is the httpMoqParam argument value. - HttpMoqParam interface{} - // Srv is the srv argument value. - Srv *http.Server - } + ShadowThree []ShadowerMockShadowThreeCalls // ShadowTwo holds details about calls to the ShadowTwo method. - ShadowTwo []struct { - // R is the r argument value. - R io.Reader - // IoMoqParam is the ioMoqParam argument value. - IoMoqParam interface{} - } + ShadowTwo []ShadowerMockShadowTwoCalls } lockShadow sync.RWMutex lockShadowThree sync.RWMutex lockShadowTwo sync.RWMutex } +// ShadowerMockShadowCalls holds details about calls to the Shadow method. +type ShadowerMockShadowCalls struct { + // IoMoqParam is the ioMoqParam argument value. + IoMoqParam io.Reader +} + +// ShadowerMockShadowThreeCalls holds details about calls to the ShadowThree method. +type ShadowerMockShadowThreeCalls struct { + // HttpMoqParam is the httpMoqParam argument value. + HttpMoqParam interface{} + // Srv is the srv argument value. + Srv *http.Server +} + +// ShadowerMockShadowTwoCalls holds details about calls to the ShadowTwo method. +type ShadowerMockShadowTwoCalls struct { + // R is the r argument value. + R io.Reader + // IoMoqParam is the ioMoqParam argument value. + IoMoqParam interface{} +} + // Shadow calls ShadowFunc. func (mock *ShadowerMock) Shadow(ioMoqParam io.Reader) { if mock.ShadowFunc == nil { panic("ShadowerMock.ShadowFunc: method is nil but Shadower.Shadow was just called") } - callInfo := struct { - IoMoqParam io.Reader - }{ + callInfo := ShadowerMockShadowCalls{ IoMoqParam: ioMoqParam, } mock.lockShadow.Lock() @@ -91,12 +99,8 @@ func (mock *ShadowerMock) Shadow(ioMoqParam io.Reader) { // Check the length with: // // len(mockedShadower.ShadowCalls()) -func (mock *ShadowerMock) ShadowCalls() []struct { - IoMoqParam io.Reader -} { - var calls []struct { - IoMoqParam io.Reader - } +func (mock *ShadowerMock) ShadowCalls() []ShadowerMockShadowCalls { + var calls []ShadowerMockShadowCalls mock.lockShadow.RLock() calls = mock.calls.Shadow mock.lockShadow.RUnlock() @@ -108,10 +112,7 @@ func (mock *ShadowerMock) ShadowThree(httpMoqParam interface{}, srv *http.Server if mock.ShadowThreeFunc == nil { panic("ShadowerMock.ShadowThreeFunc: method is nil but Shadower.ShadowThree was just called") } - callInfo := struct { - HttpMoqParam interface{} - Srv *http.Server - }{ + callInfo := ShadowerMockShadowThreeCalls{ HttpMoqParam: httpMoqParam, Srv: srv, } @@ -125,14 +126,8 @@ func (mock *ShadowerMock) ShadowThree(httpMoqParam interface{}, srv *http.Server // Check the length with: // // len(mockedShadower.ShadowThreeCalls()) -func (mock *ShadowerMock) ShadowThreeCalls() []struct { - HttpMoqParam interface{} - Srv *http.Server -} { - var calls []struct { - HttpMoqParam interface{} - Srv *http.Server - } +func (mock *ShadowerMock) ShadowThreeCalls() []ShadowerMockShadowThreeCalls { + var calls []ShadowerMockShadowThreeCalls mock.lockShadowThree.RLock() calls = mock.calls.ShadowThree mock.lockShadowThree.RUnlock() @@ -144,10 +139,7 @@ func (mock *ShadowerMock) ShadowTwo(r io.Reader, ioMoqParam interface{}) { if mock.ShadowTwoFunc == nil { panic("ShadowerMock.ShadowTwoFunc: method is nil but Shadower.ShadowTwo was just called") } - callInfo := struct { - R io.Reader - IoMoqParam interface{} - }{ + callInfo := ShadowerMockShadowTwoCalls{ R: r, IoMoqParam: ioMoqParam, } @@ -161,14 +153,8 @@ func (mock *ShadowerMock) ShadowTwo(r io.Reader, ioMoqParam interface{}) { // Check the length with: // // len(mockedShadower.ShadowTwoCalls()) -func (mock *ShadowerMock) ShadowTwoCalls() []struct { - R io.Reader - IoMoqParam interface{} -} { - var calls []struct { - R io.Reader - IoMoqParam interface{} - } +func (mock *ShadowerMock) ShadowTwoCalls() []ShadowerMockShadowTwoCalls { + var calls []ShadowerMockShadowTwoCalls mock.lockShadowTwo.RLock() calls = mock.calls.ShadowTwo mock.lockShadowTwo.RUnlock() diff --git a/pkg/moq/testpackages/shadowtypes/shadowtypes_moq.golden.go b/pkg/moq/testpackages/shadowtypes/shadowtypes_moq.golden.go index a276431..e28dd50 100644 --- a/pkg/moq/testpackages/shadowtypes/shadowtypes_moq.golden.go +++ b/pkg/moq/testpackages/shadowtypes/shadowtypes_moq.golden.go @@ -81,6 +81,7 @@ var _ ShadowTypes = &ShadowTypesMock{} // // and then make assertions. // // } + type ShadowTypesMock struct { // ShadowBoolFunc mocks the ShadowBool method. ShadowBoolFunc func(b bool, boolMoqParam types.Bool) @@ -142,138 +143,43 @@ type ShadowTypesMock struct { // calls tracks calls to the methods. calls struct { // ShadowBool holds details about calls to the ShadowBool method. - ShadowBool []struct { - // B is the b argument value. - B bool - // BoolMoqParam is the boolMoqParam argument value. - BoolMoqParam types.Bool - } + ShadowBool []ShadowTypesMockShadowBoolCalls // ShadowByte holds details about calls to the ShadowByte method. - ShadowByte []struct { - // V is the v argument value. - V byte - // ByteMoqParam is the byteMoqParam argument value. - ByteMoqParam types.Byte - } + ShadowByte []ShadowTypesMockShadowByteCalls // ShadowComplex128 holds details about calls to the ShadowComplex128 method. - ShadowComplex128 []struct { - // V is the v argument value. - V complex128 - // Complex128MoqParam is the complex128MoqParam argument value. - Complex128MoqParam types.Complex128 - } + ShadowComplex128 []ShadowTypesMockShadowComplex128Calls // ShadowComplex64 holds details about calls to the ShadowComplex64 method. - ShadowComplex64 []struct { - // V is the v argument value. - V complex64 - // Complex64MoqParam is the complex64MoqParam argument value. - Complex64MoqParam types.Complex64 - } + ShadowComplex64 []ShadowTypesMockShadowComplex64Calls // ShadowFloat32 holds details about calls to the ShadowFloat32 method. - ShadowFloat32 []struct { - // F is the f argument value. - F float32 - // Float32MoqParam is the float32MoqParam argument value. - Float32MoqParam types.Float32 - } + ShadowFloat32 []ShadowTypesMockShadowFloat32Calls // ShadowFloat64 holds details about calls to the ShadowFloat64 method. - ShadowFloat64 []struct { - // F is the f argument value. - F float64 - // Float64MoqParam is the float64MoqParam argument value. - Float64MoqParam types.Float64 - } + ShadowFloat64 []ShadowTypesMockShadowFloat64Calls // ShadowInt holds details about calls to the ShadowInt method. - ShadowInt []struct { - // N is the n argument value. - N int - // IntMoqParam is the intMoqParam argument value. - IntMoqParam types.Int - } + ShadowInt []ShadowTypesMockShadowIntCalls // ShadowInt16 holds details about calls to the ShadowInt16 method. - ShadowInt16 []struct { - // N is the n argument value. - N int16 - // Int16MoqParam is the int16MoqParam argument value. - Int16MoqParam types.Int16 - } + ShadowInt16 []ShadowTypesMockShadowInt16Calls // ShadowInt32 holds details about calls to the ShadowInt32 method. - ShadowInt32 []struct { - // N is the n argument value. - N int32 - // Int32MoqParam is the int32MoqParam argument value. - Int32MoqParam types.Int32 - } + ShadowInt32 []ShadowTypesMockShadowInt32Calls // ShadowInt64 holds details about calls to the ShadowInt64 method. - ShadowInt64 []struct { - // N is the n argument value. - N int64 - // Int64MoqParam is the int64MoqParam argument value. - Int64MoqParam types.Int64 - } + ShadowInt64 []ShadowTypesMockShadowInt64Calls // ShadowInt8 holds details about calls to the ShadowInt8 method. - ShadowInt8 []struct { - // N is the n argument value. - N int8 - // Int8MoqParam is the int8MoqParam argument value. - Int8MoqParam types.Int8 - } + ShadowInt8 []ShadowTypesMockShadowInt8Calls // ShadowRune holds details about calls to the ShadowRune method. - ShadowRune []struct { - // N is the n argument value. - N rune - // RuneMoqParam is the runeMoqParam argument value. - RuneMoqParam types.Rune - } + ShadowRune []ShadowTypesMockShadowRuneCalls // ShadowString holds details about calls to the ShadowString method. - ShadowString []struct { - // S is the s argument value. - S string - // StringMoqParam is the stringMoqParam argument value. - StringMoqParam types.String - } + ShadowString []ShadowTypesMockShadowStringCalls // ShadowUint holds details about calls to the ShadowUint method. - ShadowUint []struct { - // V is the v argument value. - V uint - // UintMoqParam is the uintMoqParam argument value. - UintMoqParam types.Uint - } + ShadowUint []ShadowTypesMockShadowUintCalls // ShadowUint16 holds details about calls to the ShadowUint16 method. - ShadowUint16 []struct { - // V is the v argument value. - V uint16 - // Uint16MoqParam is the uint16MoqParam argument value. - Uint16MoqParam types.Uint16 - } + ShadowUint16 []ShadowTypesMockShadowUint16Calls // ShadowUint32 holds details about calls to the ShadowUint32 method. - ShadowUint32 []struct { - // V is the v argument value. - V uint32 - // Uint32MoqParam is the uint32MoqParam argument value. - Uint32MoqParam types.Uint32 - } + ShadowUint32 []ShadowTypesMockShadowUint32Calls // ShadowUint64 holds details about calls to the ShadowUint64 method. - ShadowUint64 []struct { - // V is the v argument value. - V uint64 - // Uint64MoqParam is the uint64MoqParam argument value. - Uint64MoqParam types.Uint64 - } + ShadowUint64 []ShadowTypesMockShadowUint64Calls // ShadowUint8 holds details about calls to the ShadowUint8 method. - ShadowUint8 []struct { - // V is the v argument value. - V uint8 - // Uint8MoqParam is the uint8MoqParam argument value. - Uint8MoqParam types.Uint8 - } + ShadowUint8 []ShadowTypesMockShadowUint8Calls // ShadowUintptr holds details about calls to the ShadowUintptr method. - ShadowUintptr []struct { - // V is the v argument value. - V uintptr - // UintptrMoqParam is the uintptrMoqParam argument value. - UintptrMoqParam types.Uintptr - } + ShadowUintptr []ShadowTypesMockShadowUintptrCalls } lockShadowBool sync.RWMutex lockShadowByte sync.RWMutex @@ -296,15 +202,164 @@ type ShadowTypesMock struct { lockShadowUintptr sync.RWMutex } +// ShadowTypesMockShadowBoolCalls holds details about calls to the ShadowBool method. +type ShadowTypesMockShadowBoolCalls struct { + // B is the b argument value. + B bool + // BoolMoqParam is the boolMoqParam argument value. + BoolMoqParam types.Bool +} + +// ShadowTypesMockShadowByteCalls holds details about calls to the ShadowByte method. +type ShadowTypesMockShadowByteCalls struct { + // V is the v argument value. + V byte + // ByteMoqParam is the byteMoqParam argument value. + ByteMoqParam types.Byte +} + +// ShadowTypesMockShadowComplex128Calls holds details about calls to the ShadowComplex128 method. +type ShadowTypesMockShadowComplex128Calls struct { + // V is the v argument value. + V complex128 + // Complex128MoqParam is the complex128MoqParam argument value. + Complex128MoqParam types.Complex128 +} + +// ShadowTypesMockShadowComplex64Calls holds details about calls to the ShadowComplex64 method. +type ShadowTypesMockShadowComplex64Calls struct { + // V is the v argument value. + V complex64 + // Complex64MoqParam is the complex64MoqParam argument value. + Complex64MoqParam types.Complex64 +} + +// ShadowTypesMockShadowFloat32Calls holds details about calls to the ShadowFloat32 method. +type ShadowTypesMockShadowFloat32Calls struct { + // F is the f argument value. + F float32 + // Float32MoqParam is the float32MoqParam argument value. + Float32MoqParam types.Float32 +} + +// ShadowTypesMockShadowFloat64Calls holds details about calls to the ShadowFloat64 method. +type ShadowTypesMockShadowFloat64Calls struct { + // F is the f argument value. + F float64 + // Float64MoqParam is the float64MoqParam argument value. + Float64MoqParam types.Float64 +} + +// ShadowTypesMockShadowIntCalls holds details about calls to the ShadowInt method. +type ShadowTypesMockShadowIntCalls struct { + // N is the n argument value. + N int + // IntMoqParam is the intMoqParam argument value. + IntMoqParam types.Int +} + +// ShadowTypesMockShadowInt16Calls holds details about calls to the ShadowInt16 method. +type ShadowTypesMockShadowInt16Calls struct { + // N is the n argument value. + N int16 + // Int16MoqParam is the int16MoqParam argument value. + Int16MoqParam types.Int16 +} + +// ShadowTypesMockShadowInt32Calls holds details about calls to the ShadowInt32 method. +type ShadowTypesMockShadowInt32Calls struct { + // N is the n argument value. + N int32 + // Int32MoqParam is the int32MoqParam argument value. + Int32MoqParam types.Int32 +} + +// ShadowTypesMockShadowInt64Calls holds details about calls to the ShadowInt64 method. +type ShadowTypesMockShadowInt64Calls struct { + // N is the n argument value. + N int64 + // Int64MoqParam is the int64MoqParam argument value. + Int64MoqParam types.Int64 +} + +// ShadowTypesMockShadowInt8Calls holds details about calls to the ShadowInt8 method. +type ShadowTypesMockShadowInt8Calls struct { + // N is the n argument value. + N int8 + // Int8MoqParam is the int8MoqParam argument value. + Int8MoqParam types.Int8 +} + +// ShadowTypesMockShadowRuneCalls holds details about calls to the ShadowRune method. +type ShadowTypesMockShadowRuneCalls struct { + // N is the n argument value. + N rune + // RuneMoqParam is the runeMoqParam argument value. + RuneMoqParam types.Rune +} + +// ShadowTypesMockShadowStringCalls holds details about calls to the ShadowString method. +type ShadowTypesMockShadowStringCalls struct { + // S is the s argument value. + S string + // StringMoqParam is the stringMoqParam argument value. + StringMoqParam types.String +} + +// ShadowTypesMockShadowUintCalls holds details about calls to the ShadowUint method. +type ShadowTypesMockShadowUintCalls struct { + // V is the v argument value. + V uint + // UintMoqParam is the uintMoqParam argument value. + UintMoqParam types.Uint +} + +// ShadowTypesMockShadowUint16Calls holds details about calls to the ShadowUint16 method. +type ShadowTypesMockShadowUint16Calls struct { + // V is the v argument value. + V uint16 + // Uint16MoqParam is the uint16MoqParam argument value. + Uint16MoqParam types.Uint16 +} + +// ShadowTypesMockShadowUint32Calls holds details about calls to the ShadowUint32 method. +type ShadowTypesMockShadowUint32Calls struct { + // V is the v argument value. + V uint32 + // Uint32MoqParam is the uint32MoqParam argument value. + Uint32MoqParam types.Uint32 +} + +// ShadowTypesMockShadowUint64Calls holds details about calls to the ShadowUint64 method. +type ShadowTypesMockShadowUint64Calls struct { + // V is the v argument value. + V uint64 + // Uint64MoqParam is the uint64MoqParam argument value. + Uint64MoqParam types.Uint64 +} + +// ShadowTypesMockShadowUint8Calls holds details about calls to the ShadowUint8 method. +type ShadowTypesMockShadowUint8Calls struct { + // V is the v argument value. + V uint8 + // Uint8MoqParam is the uint8MoqParam argument value. + Uint8MoqParam types.Uint8 +} + +// ShadowTypesMockShadowUintptrCalls holds details about calls to the ShadowUintptr method. +type ShadowTypesMockShadowUintptrCalls struct { + // V is the v argument value. + V uintptr + // UintptrMoqParam is the uintptrMoqParam argument value. + UintptrMoqParam types.Uintptr +} + // ShadowBool calls ShadowBoolFunc. func (mock *ShadowTypesMock) ShadowBool(b bool, boolMoqParam types.Bool) { if mock.ShadowBoolFunc == nil { panic("ShadowTypesMock.ShadowBoolFunc: method is nil but ShadowTypes.ShadowBool was just called") } - callInfo := struct { - B bool - BoolMoqParam types.Bool - }{ + callInfo := ShadowTypesMockShadowBoolCalls{ B: b, BoolMoqParam: boolMoqParam, } @@ -318,14 +373,8 @@ func (mock *ShadowTypesMock) ShadowBool(b bool, boolMoqParam types.Bool) { // Check the length with: // // len(mockedShadowTypes.ShadowBoolCalls()) -func (mock *ShadowTypesMock) ShadowBoolCalls() []struct { - B bool - BoolMoqParam types.Bool -} { - var calls []struct { - B bool - BoolMoqParam types.Bool - } +func (mock *ShadowTypesMock) ShadowBoolCalls() []ShadowTypesMockShadowBoolCalls { + var calls []ShadowTypesMockShadowBoolCalls mock.lockShadowBool.RLock() calls = mock.calls.ShadowBool mock.lockShadowBool.RUnlock() @@ -337,10 +386,7 @@ func (mock *ShadowTypesMock) ShadowByte(v byte, byteMoqParam types.Byte) { if mock.ShadowByteFunc == nil { panic("ShadowTypesMock.ShadowByteFunc: method is nil but ShadowTypes.ShadowByte was just called") } - callInfo := struct { - V byte - ByteMoqParam types.Byte - }{ + callInfo := ShadowTypesMockShadowByteCalls{ V: v, ByteMoqParam: byteMoqParam, } @@ -354,14 +400,8 @@ func (mock *ShadowTypesMock) ShadowByte(v byte, byteMoqParam types.Byte) { // Check the length with: // // len(mockedShadowTypes.ShadowByteCalls()) -func (mock *ShadowTypesMock) ShadowByteCalls() []struct { - V byte - ByteMoqParam types.Byte -} { - var calls []struct { - V byte - ByteMoqParam types.Byte - } +func (mock *ShadowTypesMock) ShadowByteCalls() []ShadowTypesMockShadowByteCalls { + var calls []ShadowTypesMockShadowByteCalls mock.lockShadowByte.RLock() calls = mock.calls.ShadowByte mock.lockShadowByte.RUnlock() @@ -373,10 +413,7 @@ func (mock *ShadowTypesMock) ShadowComplex128(v complex128, complex128MoqParam t if mock.ShadowComplex128Func == nil { panic("ShadowTypesMock.ShadowComplex128Func: method is nil but ShadowTypes.ShadowComplex128 was just called") } - callInfo := struct { - V complex128 - Complex128MoqParam types.Complex128 - }{ + callInfo := ShadowTypesMockShadowComplex128Calls{ V: v, Complex128MoqParam: complex128MoqParam, } @@ -390,14 +427,8 @@ func (mock *ShadowTypesMock) ShadowComplex128(v complex128, complex128MoqParam t // Check the length with: // // len(mockedShadowTypes.ShadowComplex128Calls()) -func (mock *ShadowTypesMock) ShadowComplex128Calls() []struct { - V complex128 - Complex128MoqParam types.Complex128 -} { - var calls []struct { - V complex128 - Complex128MoqParam types.Complex128 - } +func (mock *ShadowTypesMock) ShadowComplex128Calls() []ShadowTypesMockShadowComplex128Calls { + var calls []ShadowTypesMockShadowComplex128Calls mock.lockShadowComplex128.RLock() calls = mock.calls.ShadowComplex128 mock.lockShadowComplex128.RUnlock() @@ -409,10 +440,7 @@ func (mock *ShadowTypesMock) ShadowComplex64(v complex64, complex64MoqParam type if mock.ShadowComplex64Func == nil { panic("ShadowTypesMock.ShadowComplex64Func: method is nil but ShadowTypes.ShadowComplex64 was just called") } - callInfo := struct { - V complex64 - Complex64MoqParam types.Complex64 - }{ + callInfo := ShadowTypesMockShadowComplex64Calls{ V: v, Complex64MoqParam: complex64MoqParam, } @@ -426,14 +454,8 @@ func (mock *ShadowTypesMock) ShadowComplex64(v complex64, complex64MoqParam type // Check the length with: // // len(mockedShadowTypes.ShadowComplex64Calls()) -func (mock *ShadowTypesMock) ShadowComplex64Calls() []struct { - V complex64 - Complex64MoqParam types.Complex64 -} { - var calls []struct { - V complex64 - Complex64MoqParam types.Complex64 - } +func (mock *ShadowTypesMock) ShadowComplex64Calls() []ShadowTypesMockShadowComplex64Calls { + var calls []ShadowTypesMockShadowComplex64Calls mock.lockShadowComplex64.RLock() calls = mock.calls.ShadowComplex64 mock.lockShadowComplex64.RUnlock() @@ -445,10 +467,7 @@ func (mock *ShadowTypesMock) ShadowFloat32(f float32, float32MoqParam types.Floa if mock.ShadowFloat32Func == nil { panic("ShadowTypesMock.ShadowFloat32Func: method is nil but ShadowTypes.ShadowFloat32 was just called") } - callInfo := struct { - F float32 - Float32MoqParam types.Float32 - }{ + callInfo := ShadowTypesMockShadowFloat32Calls{ F: f, Float32MoqParam: float32MoqParam, } @@ -462,14 +481,8 @@ func (mock *ShadowTypesMock) ShadowFloat32(f float32, float32MoqParam types.Floa // Check the length with: // // len(mockedShadowTypes.ShadowFloat32Calls()) -func (mock *ShadowTypesMock) ShadowFloat32Calls() []struct { - F float32 - Float32MoqParam types.Float32 -} { - var calls []struct { - F float32 - Float32MoqParam types.Float32 - } +func (mock *ShadowTypesMock) ShadowFloat32Calls() []ShadowTypesMockShadowFloat32Calls { + var calls []ShadowTypesMockShadowFloat32Calls mock.lockShadowFloat32.RLock() calls = mock.calls.ShadowFloat32 mock.lockShadowFloat32.RUnlock() @@ -481,10 +494,7 @@ func (mock *ShadowTypesMock) ShadowFloat64(f float64, float64MoqParam types.Floa if mock.ShadowFloat64Func == nil { panic("ShadowTypesMock.ShadowFloat64Func: method is nil but ShadowTypes.ShadowFloat64 was just called") } - callInfo := struct { - F float64 - Float64MoqParam types.Float64 - }{ + callInfo := ShadowTypesMockShadowFloat64Calls{ F: f, Float64MoqParam: float64MoqParam, } @@ -498,14 +508,8 @@ func (mock *ShadowTypesMock) ShadowFloat64(f float64, float64MoqParam types.Floa // Check the length with: // // len(mockedShadowTypes.ShadowFloat64Calls()) -func (mock *ShadowTypesMock) ShadowFloat64Calls() []struct { - F float64 - Float64MoqParam types.Float64 -} { - var calls []struct { - F float64 - Float64MoqParam types.Float64 - } +func (mock *ShadowTypesMock) ShadowFloat64Calls() []ShadowTypesMockShadowFloat64Calls { + var calls []ShadowTypesMockShadowFloat64Calls mock.lockShadowFloat64.RLock() calls = mock.calls.ShadowFloat64 mock.lockShadowFloat64.RUnlock() @@ -517,10 +521,7 @@ func (mock *ShadowTypesMock) ShadowInt(n int, intMoqParam types.Int) { if mock.ShadowIntFunc == nil { panic("ShadowTypesMock.ShadowIntFunc: method is nil but ShadowTypes.ShadowInt was just called") } - callInfo := struct { - N int - IntMoqParam types.Int - }{ + callInfo := ShadowTypesMockShadowIntCalls{ N: n, IntMoqParam: intMoqParam, } @@ -534,14 +535,8 @@ func (mock *ShadowTypesMock) ShadowInt(n int, intMoqParam types.Int) { // Check the length with: // // len(mockedShadowTypes.ShadowIntCalls()) -func (mock *ShadowTypesMock) ShadowIntCalls() []struct { - N int - IntMoqParam types.Int -} { - var calls []struct { - N int - IntMoqParam types.Int - } +func (mock *ShadowTypesMock) ShadowIntCalls() []ShadowTypesMockShadowIntCalls { + var calls []ShadowTypesMockShadowIntCalls mock.lockShadowInt.RLock() calls = mock.calls.ShadowInt mock.lockShadowInt.RUnlock() @@ -553,10 +548,7 @@ func (mock *ShadowTypesMock) ShadowInt16(n int16, int16MoqParam types.Int16) { if mock.ShadowInt16Func == nil { panic("ShadowTypesMock.ShadowInt16Func: method is nil but ShadowTypes.ShadowInt16 was just called") } - callInfo := struct { - N int16 - Int16MoqParam types.Int16 - }{ + callInfo := ShadowTypesMockShadowInt16Calls{ N: n, Int16MoqParam: int16MoqParam, } @@ -570,14 +562,8 @@ func (mock *ShadowTypesMock) ShadowInt16(n int16, int16MoqParam types.Int16) { // Check the length with: // // len(mockedShadowTypes.ShadowInt16Calls()) -func (mock *ShadowTypesMock) ShadowInt16Calls() []struct { - N int16 - Int16MoqParam types.Int16 -} { - var calls []struct { - N int16 - Int16MoqParam types.Int16 - } +func (mock *ShadowTypesMock) ShadowInt16Calls() []ShadowTypesMockShadowInt16Calls { + var calls []ShadowTypesMockShadowInt16Calls mock.lockShadowInt16.RLock() calls = mock.calls.ShadowInt16 mock.lockShadowInt16.RUnlock() @@ -589,10 +575,7 @@ func (mock *ShadowTypesMock) ShadowInt32(n int32, int32MoqParam types.Int32) { if mock.ShadowInt32Func == nil { panic("ShadowTypesMock.ShadowInt32Func: method is nil but ShadowTypes.ShadowInt32 was just called") } - callInfo := struct { - N int32 - Int32MoqParam types.Int32 - }{ + callInfo := ShadowTypesMockShadowInt32Calls{ N: n, Int32MoqParam: int32MoqParam, } @@ -606,14 +589,8 @@ func (mock *ShadowTypesMock) ShadowInt32(n int32, int32MoqParam types.Int32) { // Check the length with: // // len(mockedShadowTypes.ShadowInt32Calls()) -func (mock *ShadowTypesMock) ShadowInt32Calls() []struct { - N int32 - Int32MoqParam types.Int32 -} { - var calls []struct { - N int32 - Int32MoqParam types.Int32 - } +func (mock *ShadowTypesMock) ShadowInt32Calls() []ShadowTypesMockShadowInt32Calls { + var calls []ShadowTypesMockShadowInt32Calls mock.lockShadowInt32.RLock() calls = mock.calls.ShadowInt32 mock.lockShadowInt32.RUnlock() @@ -625,10 +602,7 @@ func (mock *ShadowTypesMock) ShadowInt64(n int64, int64MoqParam types.Int64) { if mock.ShadowInt64Func == nil { panic("ShadowTypesMock.ShadowInt64Func: method is nil but ShadowTypes.ShadowInt64 was just called") } - callInfo := struct { - N int64 - Int64MoqParam types.Int64 - }{ + callInfo := ShadowTypesMockShadowInt64Calls{ N: n, Int64MoqParam: int64MoqParam, } @@ -642,14 +616,8 @@ func (mock *ShadowTypesMock) ShadowInt64(n int64, int64MoqParam types.Int64) { // Check the length with: // // len(mockedShadowTypes.ShadowInt64Calls()) -func (mock *ShadowTypesMock) ShadowInt64Calls() []struct { - N int64 - Int64MoqParam types.Int64 -} { - var calls []struct { - N int64 - Int64MoqParam types.Int64 - } +func (mock *ShadowTypesMock) ShadowInt64Calls() []ShadowTypesMockShadowInt64Calls { + var calls []ShadowTypesMockShadowInt64Calls mock.lockShadowInt64.RLock() calls = mock.calls.ShadowInt64 mock.lockShadowInt64.RUnlock() @@ -661,10 +629,7 @@ func (mock *ShadowTypesMock) ShadowInt8(n int8, int8MoqParam types.Int8) { if mock.ShadowInt8Func == nil { panic("ShadowTypesMock.ShadowInt8Func: method is nil but ShadowTypes.ShadowInt8 was just called") } - callInfo := struct { - N int8 - Int8MoqParam types.Int8 - }{ + callInfo := ShadowTypesMockShadowInt8Calls{ N: n, Int8MoqParam: int8MoqParam, } @@ -678,14 +643,8 @@ func (mock *ShadowTypesMock) ShadowInt8(n int8, int8MoqParam types.Int8) { // Check the length with: // // len(mockedShadowTypes.ShadowInt8Calls()) -func (mock *ShadowTypesMock) ShadowInt8Calls() []struct { - N int8 - Int8MoqParam types.Int8 -} { - var calls []struct { - N int8 - Int8MoqParam types.Int8 - } +func (mock *ShadowTypesMock) ShadowInt8Calls() []ShadowTypesMockShadowInt8Calls { + var calls []ShadowTypesMockShadowInt8Calls mock.lockShadowInt8.RLock() calls = mock.calls.ShadowInt8 mock.lockShadowInt8.RUnlock() @@ -697,10 +656,7 @@ func (mock *ShadowTypesMock) ShadowRune(n rune, runeMoqParam types.Rune) { if mock.ShadowRuneFunc == nil { panic("ShadowTypesMock.ShadowRuneFunc: method is nil but ShadowTypes.ShadowRune was just called") } - callInfo := struct { - N rune - RuneMoqParam types.Rune - }{ + callInfo := ShadowTypesMockShadowRuneCalls{ N: n, RuneMoqParam: runeMoqParam, } @@ -714,14 +670,8 @@ func (mock *ShadowTypesMock) ShadowRune(n rune, runeMoqParam types.Rune) { // Check the length with: // // len(mockedShadowTypes.ShadowRuneCalls()) -func (mock *ShadowTypesMock) ShadowRuneCalls() []struct { - N rune - RuneMoqParam types.Rune -} { - var calls []struct { - N rune - RuneMoqParam types.Rune - } +func (mock *ShadowTypesMock) ShadowRuneCalls() []ShadowTypesMockShadowRuneCalls { + var calls []ShadowTypesMockShadowRuneCalls mock.lockShadowRune.RLock() calls = mock.calls.ShadowRune mock.lockShadowRune.RUnlock() @@ -733,10 +683,7 @@ func (mock *ShadowTypesMock) ShadowString(s string, stringMoqParam types.String) if mock.ShadowStringFunc == nil { panic("ShadowTypesMock.ShadowStringFunc: method is nil but ShadowTypes.ShadowString was just called") } - callInfo := struct { - S string - StringMoqParam types.String - }{ + callInfo := ShadowTypesMockShadowStringCalls{ S: s, StringMoqParam: stringMoqParam, } @@ -750,14 +697,8 @@ func (mock *ShadowTypesMock) ShadowString(s string, stringMoqParam types.String) // Check the length with: // // len(mockedShadowTypes.ShadowStringCalls()) -func (mock *ShadowTypesMock) ShadowStringCalls() []struct { - S string - StringMoqParam types.String -} { - var calls []struct { - S string - StringMoqParam types.String - } +func (mock *ShadowTypesMock) ShadowStringCalls() []ShadowTypesMockShadowStringCalls { + var calls []ShadowTypesMockShadowStringCalls mock.lockShadowString.RLock() calls = mock.calls.ShadowString mock.lockShadowString.RUnlock() @@ -769,10 +710,7 @@ func (mock *ShadowTypesMock) ShadowUint(v uint, uintMoqParam types.Uint) { if mock.ShadowUintFunc == nil { panic("ShadowTypesMock.ShadowUintFunc: method is nil but ShadowTypes.ShadowUint was just called") } - callInfo := struct { - V uint - UintMoqParam types.Uint - }{ + callInfo := ShadowTypesMockShadowUintCalls{ V: v, UintMoqParam: uintMoqParam, } @@ -786,14 +724,8 @@ func (mock *ShadowTypesMock) ShadowUint(v uint, uintMoqParam types.Uint) { // Check the length with: // // len(mockedShadowTypes.ShadowUintCalls()) -func (mock *ShadowTypesMock) ShadowUintCalls() []struct { - V uint - UintMoqParam types.Uint -} { - var calls []struct { - V uint - UintMoqParam types.Uint - } +func (mock *ShadowTypesMock) ShadowUintCalls() []ShadowTypesMockShadowUintCalls { + var calls []ShadowTypesMockShadowUintCalls mock.lockShadowUint.RLock() calls = mock.calls.ShadowUint mock.lockShadowUint.RUnlock() @@ -805,10 +737,7 @@ func (mock *ShadowTypesMock) ShadowUint16(v uint16, uint16MoqParam types.Uint16) if mock.ShadowUint16Func == nil { panic("ShadowTypesMock.ShadowUint16Func: method is nil but ShadowTypes.ShadowUint16 was just called") } - callInfo := struct { - V uint16 - Uint16MoqParam types.Uint16 - }{ + callInfo := ShadowTypesMockShadowUint16Calls{ V: v, Uint16MoqParam: uint16MoqParam, } @@ -822,14 +751,8 @@ func (mock *ShadowTypesMock) ShadowUint16(v uint16, uint16MoqParam types.Uint16) // Check the length with: // // len(mockedShadowTypes.ShadowUint16Calls()) -func (mock *ShadowTypesMock) ShadowUint16Calls() []struct { - V uint16 - Uint16MoqParam types.Uint16 -} { - var calls []struct { - V uint16 - Uint16MoqParam types.Uint16 - } +func (mock *ShadowTypesMock) ShadowUint16Calls() []ShadowTypesMockShadowUint16Calls { + var calls []ShadowTypesMockShadowUint16Calls mock.lockShadowUint16.RLock() calls = mock.calls.ShadowUint16 mock.lockShadowUint16.RUnlock() @@ -841,10 +764,7 @@ func (mock *ShadowTypesMock) ShadowUint32(v uint32, uint32MoqParam types.Uint32) if mock.ShadowUint32Func == nil { panic("ShadowTypesMock.ShadowUint32Func: method is nil but ShadowTypes.ShadowUint32 was just called") } - callInfo := struct { - V uint32 - Uint32MoqParam types.Uint32 - }{ + callInfo := ShadowTypesMockShadowUint32Calls{ V: v, Uint32MoqParam: uint32MoqParam, } @@ -858,14 +778,8 @@ func (mock *ShadowTypesMock) ShadowUint32(v uint32, uint32MoqParam types.Uint32) // Check the length with: // // len(mockedShadowTypes.ShadowUint32Calls()) -func (mock *ShadowTypesMock) ShadowUint32Calls() []struct { - V uint32 - Uint32MoqParam types.Uint32 -} { - var calls []struct { - V uint32 - Uint32MoqParam types.Uint32 - } +func (mock *ShadowTypesMock) ShadowUint32Calls() []ShadowTypesMockShadowUint32Calls { + var calls []ShadowTypesMockShadowUint32Calls mock.lockShadowUint32.RLock() calls = mock.calls.ShadowUint32 mock.lockShadowUint32.RUnlock() @@ -877,10 +791,7 @@ func (mock *ShadowTypesMock) ShadowUint64(v uint64, uint64MoqParam types.Uint64) if mock.ShadowUint64Func == nil { panic("ShadowTypesMock.ShadowUint64Func: method is nil but ShadowTypes.ShadowUint64 was just called") } - callInfo := struct { - V uint64 - Uint64MoqParam types.Uint64 - }{ + callInfo := ShadowTypesMockShadowUint64Calls{ V: v, Uint64MoqParam: uint64MoqParam, } @@ -894,14 +805,8 @@ func (mock *ShadowTypesMock) ShadowUint64(v uint64, uint64MoqParam types.Uint64) // Check the length with: // // len(mockedShadowTypes.ShadowUint64Calls()) -func (mock *ShadowTypesMock) ShadowUint64Calls() []struct { - V uint64 - Uint64MoqParam types.Uint64 -} { - var calls []struct { - V uint64 - Uint64MoqParam types.Uint64 - } +func (mock *ShadowTypesMock) ShadowUint64Calls() []ShadowTypesMockShadowUint64Calls { + var calls []ShadowTypesMockShadowUint64Calls mock.lockShadowUint64.RLock() calls = mock.calls.ShadowUint64 mock.lockShadowUint64.RUnlock() @@ -913,10 +818,7 @@ func (mock *ShadowTypesMock) ShadowUint8(v uint8, uint8MoqParam types.Uint8) { if mock.ShadowUint8Func == nil { panic("ShadowTypesMock.ShadowUint8Func: method is nil but ShadowTypes.ShadowUint8 was just called") } - callInfo := struct { - V uint8 - Uint8MoqParam types.Uint8 - }{ + callInfo := ShadowTypesMockShadowUint8Calls{ V: v, Uint8MoqParam: uint8MoqParam, } @@ -930,14 +832,8 @@ func (mock *ShadowTypesMock) ShadowUint8(v uint8, uint8MoqParam types.Uint8) { // Check the length with: // // len(mockedShadowTypes.ShadowUint8Calls()) -func (mock *ShadowTypesMock) ShadowUint8Calls() []struct { - V uint8 - Uint8MoqParam types.Uint8 -} { - var calls []struct { - V uint8 - Uint8MoqParam types.Uint8 - } +func (mock *ShadowTypesMock) ShadowUint8Calls() []ShadowTypesMockShadowUint8Calls { + var calls []ShadowTypesMockShadowUint8Calls mock.lockShadowUint8.RLock() calls = mock.calls.ShadowUint8 mock.lockShadowUint8.RUnlock() @@ -949,10 +845,7 @@ func (mock *ShadowTypesMock) ShadowUintptr(v uintptr, uintptrMoqParam types.Uint if mock.ShadowUintptrFunc == nil { panic("ShadowTypesMock.ShadowUintptrFunc: method is nil but ShadowTypes.ShadowUintptr was just called") } - callInfo := struct { - V uintptr - UintptrMoqParam types.Uintptr - }{ + callInfo := ShadowTypesMockShadowUintptrCalls{ V: v, UintptrMoqParam: uintptrMoqParam, } @@ -966,14 +859,8 @@ func (mock *ShadowTypesMock) ShadowUintptr(v uintptr, uintptrMoqParam types.Uint // Check the length with: // // len(mockedShadowTypes.ShadowUintptrCalls()) -func (mock *ShadowTypesMock) ShadowUintptrCalls() []struct { - V uintptr - UintptrMoqParam types.Uintptr -} { - var calls []struct { - V uintptr - UintptrMoqParam types.Uintptr - } +func (mock *ShadowTypesMock) ShadowUintptrCalls() []ShadowTypesMockShadowUintptrCalls { + var calls []ShadowTypesMockShadowUintptrCalls mock.lockShadowUintptr.RLock() calls = mock.calls.ShadowUintptr mock.lockShadowUintptr.RUnlock() diff --git a/pkg/moq/testpackages/syncimport/syncer_moq.golden.go b/pkg/moq/testpackages/syncimport/syncer_moq.golden.go index 4152269..590c4bf 100644 --- a/pkg/moq/testpackages/syncimport/syncer_moq.golden.go +++ b/pkg/moq/testpackages/syncimport/syncer_moq.golden.go @@ -27,6 +27,7 @@ var _ Syncer = &SyncerMock{} // // and then make assertions. // // } + type SyncerMock struct { // BlahFunc mocks the Blah method. BlahFunc func(s sync.Thing, wg *stdsync.WaitGroup) @@ -34,25 +35,25 @@ type SyncerMock struct { // calls tracks calls to the methods. calls struct { // Blah holds details about calls to the Blah method. - Blah []struct { - // S is the s argument value. - S sync.Thing - // Wg is the wg argument value. - Wg *stdsync.WaitGroup - } + Blah []SyncerMockBlahCalls } lockBlah stdsync.RWMutex } +// SyncerMockBlahCalls holds details about calls to the Blah method. +type SyncerMockBlahCalls struct { + // S is the s argument value. + S sync.Thing + // Wg is the wg argument value. + Wg *stdsync.WaitGroup +} + // Blah calls BlahFunc. func (mock *SyncerMock) Blah(s sync.Thing, wg *stdsync.WaitGroup) { if mock.BlahFunc == nil { panic("SyncerMock.BlahFunc: method is nil but Syncer.Blah was just called") } - callInfo := struct { - S sync.Thing - Wg *stdsync.WaitGroup - }{ + callInfo := SyncerMockBlahCalls{ S: s, Wg: wg, } @@ -66,14 +67,8 @@ func (mock *SyncerMock) Blah(s sync.Thing, wg *stdsync.WaitGroup) { // Check the length with: // // len(mockedSyncer.BlahCalls()) -func (mock *SyncerMock) BlahCalls() []struct { - S sync.Thing - Wg *stdsync.WaitGroup -} { - var calls []struct { - S sync.Thing - Wg *stdsync.WaitGroup - } +func (mock *SyncerMock) BlahCalls() []SyncerMockBlahCalls { + var calls []SyncerMockBlahCalls mock.lockBlah.RLock() calls = mock.calls.Blah mock.lockBlah.RUnlock() diff --git a/pkg/moq/testpackages/transientimport/transient_moq.golden.go b/pkg/moq/testpackages/transientimport/transient_moq.golden.go index 093351c..202ee6e 100644 --- a/pkg/moq/testpackages/transientimport/transient_moq.golden.go +++ b/pkg/moq/testpackages/transientimport/transient_moq.golden.go @@ -31,6 +31,7 @@ var _ Transient = &TransientMock{} // // and then make assertions. // // } + type TransientMock struct { // DoSomethingFunc mocks the DoSomething method. DoSomethingFunc func(zero testpackagestransientimportonev1.Zero, one transientimportonev1.One, two twoappv1.Two, three threev1.Three, four fourappv1.Four) @@ -38,34 +39,31 @@ type TransientMock struct { // calls tracks calls to the methods. calls struct { // DoSomething holds details about calls to the DoSomething method. - DoSomething []struct { - // Zero is the zero argument value. - Zero testpackagestransientimportonev1.Zero - // One is the one argument value. - One transientimportonev1.One - // Two is the two argument value. - Two twoappv1.Two - // Three is the three argument value. - Three threev1.Three - // Four is the four argument value. - Four fourappv1.Four - } + DoSomething []TransientMockDoSomethingCalls } lockDoSomething sync.RWMutex } +// TransientMockDoSomethingCalls holds details about calls to the DoSomething method. +type TransientMockDoSomethingCalls struct { + // Zero is the zero argument value. + Zero testpackagestransientimportonev1.Zero + // One is the one argument value. + One transientimportonev1.One + // Two is the two argument value. + Two twoappv1.Two + // Three is the three argument value. + Three threev1.Three + // Four is the four argument value. + Four fourappv1.Four +} + // DoSomething calls DoSomethingFunc. func (mock *TransientMock) DoSomething(zero testpackagestransientimportonev1.Zero, one transientimportonev1.One, two twoappv1.Two, three threev1.Three, four fourappv1.Four) { if mock.DoSomethingFunc == nil { panic("TransientMock.DoSomethingFunc: method is nil but Transient.DoSomething was just called") } - callInfo := struct { - Zero testpackagestransientimportonev1.Zero - One transientimportonev1.One - Two twoappv1.Two - Three threev1.Three - Four fourappv1.Four - }{ + callInfo := TransientMockDoSomethingCalls{ Zero: zero, One: one, Two: two, @@ -82,20 +80,8 @@ func (mock *TransientMock) DoSomething(zero testpackagestransientimportonev1.Zer // Check the length with: // // len(mockedTransient.DoSomethingCalls()) -func (mock *TransientMock) DoSomethingCalls() []struct { - Zero testpackagestransientimportonev1.Zero - One transientimportonev1.One - Two twoappv1.Two - Three threev1.Three - Four fourappv1.Four -} { - var calls []struct { - Zero testpackagestransientimportonev1.Zero - One transientimportonev1.One - Two twoappv1.Two - Three threev1.Three - Four fourappv1.Four - } +func (mock *TransientMock) DoSomethingCalls() []TransientMockDoSomethingCalls { + var calls []TransientMockDoSomethingCalls mock.lockDoSomething.RLock() calls = mock.calls.DoSomething mock.lockDoSomething.RUnlock() diff --git a/pkg/moq/testpackages/variadic/echoer.golden.go b/pkg/moq/testpackages/variadic/echoer.golden.go index 3921246..cd368f5 100644 --- a/pkg/moq/testpackages/variadic/echoer.golden.go +++ b/pkg/moq/testpackages/variadic/echoer.golden.go @@ -26,6 +26,7 @@ var _ Echoer = &EchoerMock{} // // and then make assertions. // // } + type EchoerMock struct { // EchoFunc mocks the Echo method. EchoFunc func(ss ...string) []string @@ -33,22 +34,23 @@ type EchoerMock struct { // calls tracks calls to the methods. calls struct { // Echo holds details about calls to the Echo method. - Echo []struct { - // Ss is the ss argument value. - Ss []string - } + Echo []EchoerMockEchoCalls } lockEcho sync.RWMutex } +// EchoerMockEchoCalls holds details about calls to the Echo method. +type EchoerMockEchoCalls struct { + // Ss is the ss argument value. + Ss []string +} + // Echo calls EchoFunc. func (mock *EchoerMock) Echo(ss ...string) []string { if mock.EchoFunc == nil { panic("EchoerMock.EchoFunc: method is nil but Echoer.Echo was just called") } - callInfo := struct { - Ss []string - }{ + callInfo := EchoerMockEchoCalls{ Ss: ss, } mock.lockEcho.Lock() @@ -61,12 +63,8 @@ func (mock *EchoerMock) Echo(ss ...string) []string { // Check the length with: // // len(mockedEchoer.EchoCalls()) -func (mock *EchoerMock) EchoCalls() []struct { - Ss []string -} { - var calls []struct { - Ss []string - } +func (mock *EchoerMock) EchoCalls() []EchoerMockEchoCalls { + var calls []EchoerMockEchoCalls mock.lockEcho.RLock() calls = mock.calls.Echo mock.lockEcho.RUnlock() diff --git a/pkg/moq/testpackages/withresets/withresets_moq.golden.go b/pkg/moq/testpackages/withresets/withresets_moq.golden.go index db08d32..014a494 100644 --- a/pkg/moq/testpackages/withresets/withresets_moq.golden.go +++ b/pkg/moq/testpackages/withresets/withresets_moq.golden.go @@ -33,6 +33,7 @@ var _ ResetStore = &ResetStoreMock{} // // and then make assertions. // // } + type ResetStoreMock struct { // ClearCacheFunc mocks the ClearCache method. ClearCacheFunc func(id string) @@ -46,40 +47,47 @@ type ResetStoreMock struct { // calls tracks calls to the methods. calls struct { // ClearCache holds details about calls to the ClearCache method. - ClearCache []struct { - // ID is the id argument value. - ID string - } + ClearCache []ResetStoreMockClearCacheCalls // Create holds details about calls to the Create method. - Create []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // Person is the person argument value. - Person *Reset - // Confirm is the confirm argument value. - Confirm bool - } + Create []ResetStoreMockCreateCalls // Get holds details about calls to the Get method. - Get []struct { - // Ctx is the ctx argument value. - Ctx context.Context - // ID is the id argument value. - ID string - } + Get []ResetStoreMockGetCalls } lockClearCache sync.RWMutex lockCreate sync.RWMutex lockGet sync.RWMutex } +// ResetStoreMockClearCacheCalls holds details about calls to the ClearCache method. +type ResetStoreMockClearCacheCalls struct { + // ID is the id argument value. + ID string +} + +// ResetStoreMockCreateCalls holds details about calls to the Create method. +type ResetStoreMockCreateCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // Person is the person argument value. + Person *Reset + // Confirm is the confirm argument value. + Confirm bool +} + +// ResetStoreMockGetCalls holds details about calls to the Get method. +type ResetStoreMockGetCalls struct { + // Ctx is the ctx argument value. + Ctx context.Context + // ID is the id argument value. + ID string +} + // ClearCache calls ClearCacheFunc. func (mock *ResetStoreMock) ClearCache(id string) { if mock.ClearCacheFunc == nil { panic("ResetStoreMock.ClearCacheFunc: method is nil but ResetStore.ClearCache was just called") } - callInfo := struct { - ID string - }{ + callInfo := ResetStoreMockClearCacheCalls{ ID: id, } mock.lockClearCache.Lock() @@ -92,12 +100,8 @@ func (mock *ResetStoreMock) ClearCache(id string) { // Check the length with: // // len(mockedResetStore.ClearCacheCalls()) -func (mock *ResetStoreMock) ClearCacheCalls() []struct { - ID string -} { - var calls []struct { - ID string - } +func (mock *ResetStoreMock) ClearCacheCalls() []ResetStoreMockClearCacheCalls { + var calls []ResetStoreMockClearCacheCalls mock.lockClearCache.RLock() calls = mock.calls.ClearCache mock.lockClearCache.RUnlock() @@ -116,11 +120,7 @@ func (mock *ResetStoreMock) Create(ctx context.Context, person *Reset, confirm b if mock.CreateFunc == nil { panic("ResetStoreMock.CreateFunc: method is nil but ResetStore.Create was just called") } - callInfo := struct { - Ctx context.Context - Person *Reset - Confirm bool - }{ + callInfo := ResetStoreMockCreateCalls{ Ctx: ctx, Person: person, Confirm: confirm, @@ -135,16 +135,8 @@ func (mock *ResetStoreMock) Create(ctx context.Context, person *Reset, confirm b // Check the length with: // // len(mockedResetStore.CreateCalls()) -func (mock *ResetStoreMock) CreateCalls() []struct { - Ctx context.Context - Person *Reset - Confirm bool -} { - var calls []struct { - Ctx context.Context - Person *Reset - Confirm bool - } +func (mock *ResetStoreMock) CreateCalls() []ResetStoreMockCreateCalls { + var calls []ResetStoreMockCreateCalls mock.lockCreate.RLock() calls = mock.calls.Create mock.lockCreate.RUnlock() @@ -163,10 +155,7 @@ func (mock *ResetStoreMock) Get(ctx context.Context, id string) (*Reset, error) if mock.GetFunc == nil { panic("ResetStoreMock.GetFunc: method is nil but ResetStore.Get was just called") } - callInfo := struct { - Ctx context.Context - ID string - }{ + callInfo := ResetStoreMockGetCalls{ Ctx: ctx, ID: id, } @@ -180,14 +169,8 @@ func (mock *ResetStoreMock) Get(ctx context.Context, id string) (*Reset, error) // Check the length with: // // len(mockedResetStore.GetCalls()) -func (mock *ResetStoreMock) GetCalls() []struct { - Ctx context.Context - ID string -} { - var calls []struct { - Ctx context.Context - ID string - } +func (mock *ResetStoreMock) GetCalls() []ResetStoreMockGetCalls { + var calls []ResetStoreMockGetCalls mock.lockGet.RLock() calls = mock.calls.Get mock.lockGet.RUnlock()