From 3cc9013ec3cbad2b8eb4da0ce9a3bcc90d160c5a Mon Sep 17 00:00:00 2001 From: Tom Moulard Date: Fri, 6 Sep 2024 11:53:50 +0200 Subject: [PATCH] feat: support types.Struct as interface args --- mocktail.go | 7 + testdata/src/a/a.go | 1 + testdata/src/a/mock_gen_test.go | 315 +++++++++++++++++++++++++ testdata/src/a/mock_gen_test.go.golden | 315 +++++++++++++++++++++++++ testdata/src/a/mock_test.go | 2 + 5 files changed, 640 insertions(+) diff --git a/mocktail.go b/mocktail.go index c845c5d..64ea98f 100644 --- a/mocktail.go +++ b/mocktail.go @@ -216,6 +216,13 @@ func getTypeImports(t types.Type) []string { case *types.Array: return getTypeImports(v.Elem()) + case *types.Struct: + var imports []string + for i := 0; i < v.NumFields(); i++ { + imports = append(imports, getTypeImports(v.Field(i).Type())...) + } + return imports + case *types.Map: imports := getTypeImports(v.Key()) imports = append(imports, getTypeImports(v.Elem())...) diff --git a/testdata/src/a/a.go b/testdata/src/a/a.go index 5b63635..6637fff 100644 --- a/testdata/src/a/a.go +++ b/testdata/src/a/a.go @@ -31,6 +31,7 @@ type Coconut interface { Zoo(st interface{}) string Moo(fn func(st, stban Strawberry) Pineapple) string Noo(ar [][2]string) string + Poo(str struct{ name string }) string } type Water struct{} diff --git a/testdata/src/a/mock_gen_test.go b/testdata/src/a/mock_gen_test.go index b22b976..c477ba4 100644 --- a/testdata/src/a/mock_gen_test.go +++ b/testdata/src/a/mock_gen_test.go @@ -783,6 +783,10 @@ func (_c *coconutBooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutBooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutBooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -839,6 +843,10 @@ func (_c *coconutBooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutBooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutBooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -978,6 +986,10 @@ func (_c *coconutDooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutDooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutDooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1034,6 +1046,10 @@ func (_c *coconutDooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutDooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutDooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1173,6 +1189,10 @@ func (_c *coconutFooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutFooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutFooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1229,6 +1249,10 @@ func (_c *coconutFooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutFooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutFooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1368,6 +1392,10 @@ func (_c *coconutGooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutGooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutGooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1424,6 +1452,10 @@ func (_c *coconutGooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutGooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutGooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1547,6 +1579,10 @@ func (_c *coconutHooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutHooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutHooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1603,6 +1639,10 @@ func (_c *coconutHooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutHooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutHooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1745,6 +1785,10 @@ func (_c *coconutJooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutJooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutJooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1801,6 +1845,10 @@ func (_c *coconutJooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutJooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutJooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1940,6 +1988,10 @@ func (_c *coconutKooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutKooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutKooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1996,6 +2048,10 @@ func (_c *coconutKooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutKooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutKooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2136,6 +2192,10 @@ func (_c *coconutLooCall) OnNoo(ar ...[2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutLooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutLooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2192,6 +2252,10 @@ func (_c *coconutLooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutLooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutLooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2331,6 +2395,10 @@ func (_c *coconutMooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutMooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutMooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2387,6 +2455,10 @@ func (_c *coconutMooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutMooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutMooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2526,6 +2598,10 @@ func (_c *coconutNooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutNooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutNooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2582,6 +2658,10 @@ func (_c *coconutNooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutNooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutNooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2598,6 +2678,209 @@ func (_c *coconutNooCall) OnZooRaw(st interface{}) *coconutZooCall { return _c.Parent.OnZooRaw(st) } +func (_m *coconutMock) Poo(str struct{ name string }) string { + _ret := _m.Called(str) + + if _rf, ok := _ret.Get(0).(func(struct{ name string }) string); ok { + return _rf(str) + } + + _ra0 := _ret.String(0) + + return _ra0 +} + +func (_m *coconutMock) OnPoo(str struct{ name string }) *coconutPooCall { + return &coconutPooCall{Call: _m.Mock.On("Poo", str), Parent: _m} +} + +func (_m *coconutMock) OnPooRaw(str interface{}) *coconutPooCall { + return &coconutPooCall{Call: _m.Mock.On("Poo", str), Parent: _m} +} + +type coconutPooCall struct { + *mock.Call + Parent *coconutMock +} + +func (_c *coconutPooCall) Panic(msg string) *coconutPooCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *coconutPooCall) Once() *coconutPooCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *coconutPooCall) Twice() *coconutPooCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *coconutPooCall) Times(i int) *coconutPooCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *coconutPooCall) WaitUntil(w <-chan time.Time) *coconutPooCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *coconutPooCall) After(d time.Duration) *coconutPooCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *coconutPooCall) Run(fn func(args mock.Arguments)) *coconutPooCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *coconutPooCall) Maybe() *coconutPooCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *coconutPooCall) TypedReturns(a string) *coconutPooCall { + _c.Call = _c.Return(a) + return _c +} + +func (_c *coconutPooCall) ReturnsFn(fn func(struct{ name string }) string) *coconutPooCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *coconutPooCall) TypedRun(fn func(struct{ name string })) *coconutPooCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _str, _ := args.Get(0).(struct{ name string }) + fn(_str) + }) + return _c +} + +func (_c *coconutPooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { + return _c.Parent.OnBoo(src) +} + +func (_c *coconutPooCall) OnDoo(src time.Duration) *coconutDooCall { + return _c.Parent.OnDoo(src) +} + +func (_c *coconutPooCall) OnFoo(st Strawberry) *coconutFooCall { + return _c.Parent.OnFoo(st) +} + +func (_c *coconutPooCall) OnGoo(st string) *coconutGooCall { + return _c.Parent.OnGoo(st) +} + +func (_c *coconutPooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { + return _c.Parent.OnHoo(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { + return _c.Parent.OnJoo(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnKoo(src string) *coconutKooCall { + return _c.Parent.OnKoo(src) +} + +func (_c *coconutPooCall) OnLoo(st string, values []int) *coconutLooCall { + return _c.Parent.OnLoo(st, values...) +} + +func (_c *coconutPooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { + return _c.Parent.OnMoo(fn) +} + +func (_c *coconutPooCall) OnNoo(ar [][2]string) *coconutNooCall { + return _c.Parent.OnNoo(ar) +} + +func (_c *coconutPooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + +func (_c *coconutPooCall) OnToo(src string) *coconutTooCall { + return _c.Parent.OnToo(src) +} + +func (_c *coconutPooCall) OnVoo(src *module.Version) *coconutVooCall { + return _c.Parent.OnVoo(src) +} + +func (_c *coconutPooCall) OnYoo(st string) *coconutYooCall { + return _c.Parent.OnYoo(st) +} + +func (_c *coconutPooCall) OnZoo(st interface{}) *coconutZooCall { + return _c.Parent.OnZoo(st) +} + +func (_c *coconutPooCall) OnBooRaw(src interface{}) *coconutBooCall { + return _c.Parent.OnBooRaw(src) +} + +func (_c *coconutPooCall) OnDooRaw(src interface{}) *coconutDooCall { + return _c.Parent.OnDooRaw(src) +} + +func (_c *coconutPooCall) OnFooRaw(st interface{}) *coconutFooCall { + return _c.Parent.OnFooRaw(st) +} + +func (_c *coconutPooCall) OnGooRaw(st interface{}) *coconutGooCall { + return _c.Parent.OnGooRaw(st) +} + +func (_c *coconutPooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { + return _c.Parent.OnHooRaw(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { + return _c.Parent.OnJooRaw(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnKooRaw(src interface{}) *coconutKooCall { + return _c.Parent.OnKooRaw(src) +} + +func (_c *coconutPooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { + return _c.Parent.OnLooRaw(st, values) +} + +func (_c *coconutPooCall) OnMooRaw(fn interface{}) *coconutMooCall { + return _c.Parent.OnMooRaw(fn) +} + +func (_c *coconutPooCall) OnNooRaw(ar interface{}) *coconutNooCall { + return _c.Parent.OnNooRaw(ar) +} + +func (_c *coconutPooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + +func (_c *coconutPooCall) OnTooRaw(src interface{}) *coconutTooCall { + return _c.Parent.OnTooRaw(src) +} + +func (_c *coconutPooCall) OnVooRaw(src interface{}) *coconutVooCall { + return _c.Parent.OnVooRaw(src) +} + +func (_c *coconutPooCall) OnYooRaw(st interface{}) *coconutYooCall { + return _c.Parent.OnYooRaw(st) +} + +func (_c *coconutPooCall) OnZooRaw(st interface{}) *coconutZooCall { + return _c.Parent.OnZooRaw(st) +} + func (_m *coconutMock) Too(src string) time.Duration { _ret := _m.Called(src) @@ -2721,6 +3004,10 @@ func (_c *coconutTooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutTooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutTooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2777,6 +3064,10 @@ func (_c *coconutTooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutTooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutTooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2916,6 +3207,10 @@ func (_c *coconutVooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutVooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutVooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2972,6 +3267,10 @@ func (_c *coconutVooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutVooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutVooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -3111,6 +3410,10 @@ func (_c *coconutYooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutYooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutYooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -3167,6 +3470,10 @@ func (_c *coconutYooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutYooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutYooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -3306,6 +3613,10 @@ func (_c *coconutZooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutZooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutZooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -3362,6 +3673,10 @@ func (_c *coconutZooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutZooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutZooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } diff --git a/testdata/src/a/mock_gen_test.go.golden b/testdata/src/a/mock_gen_test.go.golden index b22b976..c477ba4 100644 --- a/testdata/src/a/mock_gen_test.go.golden +++ b/testdata/src/a/mock_gen_test.go.golden @@ -783,6 +783,10 @@ func (_c *coconutBooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutBooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutBooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -839,6 +843,10 @@ func (_c *coconutBooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutBooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutBooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -978,6 +986,10 @@ func (_c *coconutDooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutDooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutDooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1034,6 +1046,10 @@ func (_c *coconutDooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutDooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutDooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1173,6 +1189,10 @@ func (_c *coconutFooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutFooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutFooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1229,6 +1249,10 @@ func (_c *coconutFooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutFooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutFooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1368,6 +1392,10 @@ func (_c *coconutGooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutGooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutGooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1424,6 +1452,10 @@ func (_c *coconutGooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutGooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutGooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1547,6 +1579,10 @@ func (_c *coconutHooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutHooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutHooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1603,6 +1639,10 @@ func (_c *coconutHooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutHooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutHooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1745,6 +1785,10 @@ func (_c *coconutJooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutJooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutJooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1801,6 +1845,10 @@ func (_c *coconutJooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutJooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutJooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -1940,6 +1988,10 @@ func (_c *coconutKooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutKooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutKooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -1996,6 +2048,10 @@ func (_c *coconutKooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutKooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutKooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2136,6 +2192,10 @@ func (_c *coconutLooCall) OnNoo(ar ...[2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutLooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutLooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2192,6 +2252,10 @@ func (_c *coconutLooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutLooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutLooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2331,6 +2395,10 @@ func (_c *coconutMooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutMooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutMooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2387,6 +2455,10 @@ func (_c *coconutMooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutMooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutMooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2526,6 +2598,10 @@ func (_c *coconutNooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutNooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutNooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2582,6 +2658,10 @@ func (_c *coconutNooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutNooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutNooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2598,6 +2678,209 @@ func (_c *coconutNooCall) OnZooRaw(st interface{}) *coconutZooCall { return _c.Parent.OnZooRaw(st) } +func (_m *coconutMock) Poo(str struct{ name string }) string { + _ret := _m.Called(str) + + if _rf, ok := _ret.Get(0).(func(struct{ name string }) string); ok { + return _rf(str) + } + + _ra0 := _ret.String(0) + + return _ra0 +} + +func (_m *coconutMock) OnPoo(str struct{ name string }) *coconutPooCall { + return &coconutPooCall{Call: _m.Mock.On("Poo", str), Parent: _m} +} + +func (_m *coconutMock) OnPooRaw(str interface{}) *coconutPooCall { + return &coconutPooCall{Call: _m.Mock.On("Poo", str), Parent: _m} +} + +type coconutPooCall struct { + *mock.Call + Parent *coconutMock +} + +func (_c *coconutPooCall) Panic(msg string) *coconutPooCall { + _c.Call = _c.Call.Panic(msg) + return _c +} + +func (_c *coconutPooCall) Once() *coconutPooCall { + _c.Call = _c.Call.Once() + return _c +} + +func (_c *coconutPooCall) Twice() *coconutPooCall { + _c.Call = _c.Call.Twice() + return _c +} + +func (_c *coconutPooCall) Times(i int) *coconutPooCall { + _c.Call = _c.Call.Times(i) + return _c +} + +func (_c *coconutPooCall) WaitUntil(w <-chan time.Time) *coconutPooCall { + _c.Call = _c.Call.WaitUntil(w) + return _c +} + +func (_c *coconutPooCall) After(d time.Duration) *coconutPooCall { + _c.Call = _c.Call.After(d) + return _c +} + +func (_c *coconutPooCall) Run(fn func(args mock.Arguments)) *coconutPooCall { + _c.Call = _c.Call.Run(fn) + return _c +} + +func (_c *coconutPooCall) Maybe() *coconutPooCall { + _c.Call = _c.Call.Maybe() + return _c +} + +func (_c *coconutPooCall) TypedReturns(a string) *coconutPooCall { + _c.Call = _c.Return(a) + return _c +} + +func (_c *coconutPooCall) ReturnsFn(fn func(struct{ name string }) string) *coconutPooCall { + _c.Call = _c.Return(fn) + return _c +} + +func (_c *coconutPooCall) TypedRun(fn func(struct{ name string })) *coconutPooCall { + _c.Call = _c.Call.Run(func(args mock.Arguments) { + _str, _ := args.Get(0).(struct{ name string }) + fn(_str) + }) + return _c +} + +func (_c *coconutPooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { + return _c.Parent.OnBoo(src) +} + +func (_c *coconutPooCall) OnDoo(src time.Duration) *coconutDooCall { + return _c.Parent.OnDoo(src) +} + +func (_c *coconutPooCall) OnFoo(st Strawberry) *coconutFooCall { + return _c.Parent.OnFoo(st) +} + +func (_c *coconutPooCall) OnGoo(st string) *coconutGooCall { + return _c.Parent.OnGoo(st) +} + +func (_c *coconutPooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { + return _c.Parent.OnHoo(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { + return _c.Parent.OnJoo(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnKoo(src string) *coconutKooCall { + return _c.Parent.OnKoo(src) +} + +func (_c *coconutPooCall) OnLoo(st string, values []int) *coconutLooCall { + return _c.Parent.OnLoo(st, values...) +} + +func (_c *coconutPooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { + return _c.Parent.OnMoo(fn) +} + +func (_c *coconutPooCall) OnNoo(ar [][2]string) *coconutNooCall { + return _c.Parent.OnNoo(ar) +} + +func (_c *coconutPooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + +func (_c *coconutPooCall) OnToo(src string) *coconutTooCall { + return _c.Parent.OnToo(src) +} + +func (_c *coconutPooCall) OnVoo(src *module.Version) *coconutVooCall { + return _c.Parent.OnVoo(src) +} + +func (_c *coconutPooCall) OnYoo(st string) *coconutYooCall { + return _c.Parent.OnYoo(st) +} + +func (_c *coconutPooCall) OnZoo(st interface{}) *coconutZooCall { + return _c.Parent.OnZoo(st) +} + +func (_c *coconutPooCall) OnBooRaw(src interface{}) *coconutBooCall { + return _c.Parent.OnBooRaw(src) +} + +func (_c *coconutPooCall) OnDooRaw(src interface{}) *coconutDooCall { + return _c.Parent.OnDooRaw(src) +} + +func (_c *coconutPooCall) OnFooRaw(st interface{}) *coconutFooCall { + return _c.Parent.OnFooRaw(st) +} + +func (_c *coconutPooCall) OnGooRaw(st interface{}) *coconutGooCall { + return _c.Parent.OnGooRaw(st) +} + +func (_c *coconutPooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { + return _c.Parent.OnHooRaw(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { + return _c.Parent.OnJooRaw(aParam, bParam, cParam) +} + +func (_c *coconutPooCall) OnKooRaw(src interface{}) *coconutKooCall { + return _c.Parent.OnKooRaw(src) +} + +func (_c *coconutPooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { + return _c.Parent.OnLooRaw(st, values) +} + +func (_c *coconutPooCall) OnMooRaw(fn interface{}) *coconutMooCall { + return _c.Parent.OnMooRaw(fn) +} + +func (_c *coconutPooCall) OnNooRaw(ar interface{}) *coconutNooCall { + return _c.Parent.OnNooRaw(ar) +} + +func (_c *coconutPooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + +func (_c *coconutPooCall) OnTooRaw(src interface{}) *coconutTooCall { + return _c.Parent.OnTooRaw(src) +} + +func (_c *coconutPooCall) OnVooRaw(src interface{}) *coconutVooCall { + return _c.Parent.OnVooRaw(src) +} + +func (_c *coconutPooCall) OnYooRaw(st interface{}) *coconutYooCall { + return _c.Parent.OnYooRaw(st) +} + +func (_c *coconutPooCall) OnZooRaw(st interface{}) *coconutZooCall { + return _c.Parent.OnZooRaw(st) +} + func (_m *coconutMock) Too(src string) time.Duration { _ret := _m.Called(src) @@ -2721,6 +3004,10 @@ func (_c *coconutTooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutTooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutTooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2777,6 +3064,10 @@ func (_c *coconutTooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutTooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutTooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -2916,6 +3207,10 @@ func (_c *coconutVooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutVooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutVooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -2972,6 +3267,10 @@ func (_c *coconutVooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutVooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutVooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -3111,6 +3410,10 @@ func (_c *coconutYooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutYooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutYooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -3167,6 +3470,10 @@ func (_c *coconutYooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutYooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutYooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } @@ -3306,6 +3613,10 @@ func (_c *coconutZooCall) OnNoo(ar [][2]string) *coconutNooCall { return _c.Parent.OnNoo(ar) } +func (_c *coconutZooCall) OnPoo(str struct{ name string }) *coconutPooCall { + return _c.Parent.OnPoo(str) +} + func (_c *coconutZooCall) OnToo(src string) *coconutTooCall { return _c.Parent.OnToo(src) } @@ -3362,6 +3673,10 @@ func (_c *coconutZooCall) OnNooRaw(ar interface{}) *coconutNooCall { return _c.Parent.OnNooRaw(ar) } +func (_c *coconutZooCall) OnPooRaw(str interface{}) *coconutPooCall { + return _c.Parent.OnPooRaw(str) +} + func (_c *coconutZooCall) OnTooRaw(src interface{}) *coconutTooCall { return _c.Parent.OnTooRaw(src) } diff --git a/testdata/src/a/mock_test.go b/testdata/src/a/mock_test.go index 248ee62..870dce3 100644 --- a/testdata/src/a/mock_test.go +++ b/testdata/src/a/mock_test.go @@ -35,11 +35,13 @@ func TestName(t *testing.T) { OnLoo("a", 1, 2).TypedReturns("foo").Once(). OnMoo(fn).TypedReturns("").Once(). OnNoo([][2]string{{"a", "b"}}).TypedReturns(""). + OnPoo(struct{ name string }{name: "poo"}).TypedReturns("").Once(). Parent c.Loo("a", 1, 2) c.Moo(fn) c.Noo([][2]string{{"a", "b"}}) + c.Poo(struct{ name string }{name: "poo"}) juiceCh := make(chan struct{}, 1) juiceCh <- struct{}{}