diff --git a/mocks/pkg/fixtures/EmbeddedGet.go b/mocks/pkg/fixtures/EmbeddedGet.go new file mode 100644 index 00000000..87003bf7 --- /dev/null +++ b/mocks/pkg/fixtures/EmbeddedGet.go @@ -0,0 +1,42 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + constraints "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// EmbeddedGet is an autogenerated mock type for the EmbeddedGet type +type EmbeddedGet[T constraints.Signed] struct { + mock.Mock +} + +// Get provides a mock function with given fields: +func (_m *EmbeddedGet[T]) Get() T { + ret := _m.Called() + + var r0 T + if rf, ok := ret.Get(0).(func() T); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(T) + } + + return r0 +} + +type NewEmbeddedGetT interface { + mock.TestingT + Cleanup(func()) +} + +// NewEmbeddedGet creates a new instance of EmbeddedGet. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewEmbeddedGet[T constraints.Signed](t NewEmbeddedGetT) *EmbeddedGet { + mock := &EmbeddedGet[T]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/pkg/fixtures/GetGeneric.go b/mocks/pkg/fixtures/GetGeneric.go new file mode 100644 index 00000000..e31c2ac4 --- /dev/null +++ b/mocks/pkg/fixtures/GetGeneric.go @@ -0,0 +1,42 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + constraints "github.com/vektra/mockery/v2/pkg/fixtures/constraints" +) + +// GetGeneric is an autogenerated mock type for the GetGeneric type +type GetGeneric[T constraints.Integer] struct { + mock.Mock +} + +// Get provides a mock function with given fields: +func (_m *GetGeneric[T]) Get() T { + ret := _m.Called() + + var r0 T + if rf, ok := ret.Get(0).(func() T); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(T) + } + + return r0 +} + +type NewGetGenericT interface { + mock.TestingT + Cleanup(func()) +} + +// NewGetGeneric creates a new instance of GetGeneric. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewGetGeneric[T constraints.Integer](t NewGetGenericT) *GetGeneric { + mock := &GetGeneric[T]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/pkg/fixtures/GetInt.go b/mocks/pkg/fixtures/GetInt.go new file mode 100644 index 00000000..8dfe94b5 --- /dev/null +++ b/mocks/pkg/fixtures/GetInt.go @@ -0,0 +1,39 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// GetInt is an autogenerated mock type for the GetInt type +type GetInt struct { + mock.Mock +} + +// Get provides a mock function with given fields: +func (_m *GetInt) Get() int { + ret := _m.Called() + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +type NewGetIntT interface { + mock.TestingT + Cleanup(func()) +} + +// NewGetInt creates a new instance of GetInt. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewGetInt(t NewGetIntT) *GetInt { + mock := &GetInt{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/pkg/fixtures/RequesterGenerics.go b/mocks/pkg/fixtures/RequesterGenerics.go new file mode 100644 index 00000000..ef909bb0 --- /dev/null +++ b/mocks/pkg/fixtures/RequesterGenerics.go @@ -0,0 +1,96 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + io "io" + + constraints "github.com/vektra/mockery/v2/pkg/fixtures/constraints" + + mock "github.com/stretchr/testify/mock" + + test "github.com/vektra/mockery/v2/pkg/fixtures" +) + +// RequesterGenerics is an autogenerated mock type for the RequesterGenerics type +type RequesterGenerics[TAny interface{}, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { + ~int | test.GenericType[int, test.GetInt] + comparable +}] struct { + mock.Mock +} + +// GenericAnonymousStructs provides a mock function with given fields: _a0 +func (_m *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericAnonymousStructs(_a0 struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] +} { + ret := _m.Called(_a0) + + var r0 struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] + } + if rf, ok := ret.Get(0).(func(struct{ Type1 TExternalIntf }) struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] + }); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(struct { + Type2 test.GenericType[string, test.EmbeddedGet[int]] + }) + } + + return r0 +} + +// GenericArguments provides a mock function with given fields: _a0, _a1 +func (_m *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericArguments(_a0 TAny, _a1 TComparable) (TSigned, TIntf) { + ret := _m.Called(_a0, _a1) + + var r0 TSigned + if rf, ok := ret.Get(0).(func(TAny, TComparable) TSigned); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Get(0).(TSigned) + } + + var r1 TIntf + if rf, ok := ret.Get(1).(func(TAny, TComparable) TIntf); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Get(1).(TIntf) + } + + return r0, r1 +} + +// GenericStructs provides a mock function with given fields: _a0 +func (_m *RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]) GenericStructs(_a0 test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf] { + ret := _m.Called(_a0) + + var r0 test.GenericType[TSigned, TIntf] + if rf, ok := ret.Get(0).(func(test.GenericType[TAny, TIntf]) test.GenericType[TSigned, TIntf]); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(test.GenericType[TSigned, TIntf]) + } + + return r0 +} + +type NewRequesterGenericsT interface { + mock.TestingT + Cleanup(func()) +} + +// NewRequesterGenerics creates a new instance of RequesterGenerics. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewRequesterGenerics[TAny interface{}, TComparable comparable, TSigned constraints.Signed, TIntf test.GetInt, TExternalIntf io.Writer, TGenIntf test.GetGeneric[TSigned], TInlineType interface{ ~int | ~uint }, TInlineTypeGeneric interface { + ~int | test.GenericType[int, test.GetInt] + comparable +}](t NewRequesterGenericsT) *RequesterGenerics { + mock := &RequesterGenerics[TAny, TComparable, TSigned, TIntf, TExternalIntf, TGenIntf, TInlineType, TInlineTypeGeneric]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/pkg/fixtures/constraints/Integer.go b/mocks/pkg/fixtures/constraints/Integer.go new file mode 100644 index 00000000..61b21e81 --- /dev/null +++ b/mocks/pkg/fixtures/constraints/Integer.go @@ -0,0 +1,25 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Integer is an autogenerated mock type for the Integer type +type Integer struct { + mock.Mock +} + +type NewIntegerT interface { + mock.TestingT + Cleanup(func()) +} + +// NewInteger creates a new instance of Integer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewInteger(t NewIntegerT) *Integer { + mock := &Integer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/pkg/fixtures/constraints/Signed.go b/mocks/pkg/fixtures/constraints/Signed.go new file mode 100644 index 00000000..30b94696 --- /dev/null +++ b/mocks/pkg/fixtures/constraints/Signed.go @@ -0,0 +1,25 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Signed is an autogenerated mock type for the Signed type +type Signed struct { + mock.Mock +} + +type NewSignedT interface { + mock.TestingT + Cleanup(func()) +} + +// NewSigned creates a new instance of Signed. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewSigned(t NewSignedT) *Signed { + mock := &Signed{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/generator.go b/pkg/generator.go index 5151f9ad..539dc17f 100644 --- a/pkg/generator.go +++ b/pkg/generator.go @@ -814,9 +814,8 @@ type {{ .ConstructorTestingInterfaceName }} interface { } // {{ .ConstructorName }} creates a new instance of {{ .MockName }}. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func {{ .ConstructorName }}{{ .TypeConstraint }}(t {{ .ConstructorTestingInterfaceName }}) *{{ .MockName }}{{ .TypeParams }} { +func {{ .ConstructorName }}{{ .TypeConstraint }}(t {{ .ConstructorTestingInterfaceName }}) *{{ .MockName }}{{ .InstantiatedTypeString }} { mock := &{{ .MockName }}{{ .InstantiatedTypeString }}{} - mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) @@ -833,7 +832,6 @@ func {{ .ConstructorName }}{{ .TypeConstraint }}(t {{ .ConstructorTestingInterfa InstantiatedTypeString string MockName string TypeConstraint string - TypeParams string }{ ConstructorName: constructorName, ConstructorTestingInterfaceName: constructorName + "T",