From 948a829db59d7750d93579b86c22693e40dfe8b2 Mon Sep 17 00:00:00 2001 From: Franco Liberali Date: Mon, 7 Aug 2023 16:18:06 +0200 Subject: [PATCH] update mocks --- mocks/orm/Condition.go | 27 +++--------- mocks/orm/DynamicOperator.go | 82 +++++++++++++++++++++++++++++++++++ mocks/orm/IJoinCondition.go | 27 +++--------- mocks/orm/Operator.go | 27 +++++++----- mocks/orm/WhereCondition.go | 65 +++++++++++---------------- mocks/orm/iFieldIdentifier.go | 74 +++++++++++++++++++++++++++++++ 6 files changed, 211 insertions(+), 91 deletions(-) create mode 100644 mocks/orm/DynamicOperator.go create mode 100644 mocks/orm/iFieldIdentifier.go diff --git a/mocks/orm/Condition.go b/mocks/orm/Condition.go index d9775761..9edfd710 100644 --- a/mocks/orm/Condition.go +++ b/mocks/orm/Condition.go @@ -5,7 +5,6 @@ package mocks import ( orm "github.com/ditrit/badaas/orm" mock "github.com/stretchr/testify/mock" - gorm "gorm.io/gorm" ) // Condition is an autogenerated mock type for the Condition type @@ -14,33 +13,21 @@ type Condition[T orm.Model] struct { } // ApplyTo provides a mock function with given fields: query, table -func (_m *Condition[T]) ApplyTo(query *gorm.DB, table orm.Table) (*gorm.DB, error) { +func (_m *Condition[T]) ApplyTo(query *orm.Query, table orm.Table) error { ret := _m.Called(query, table) - var r0 *gorm.DB - var r1 error - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) (*gorm.DB, error)); ok { - return rf(query, table) - } - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) *gorm.DB); ok { + var r0 error + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) error); ok { r0 = rf(query, table) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gorm.DB) - } - } - - if rf, ok := ret.Get(1).(func(*gorm.DB, orm.Table) error); ok { - r1 = rf(query, table) - } else { - r1 = ret.Error(1) + r0 = ret.Error(0) } - return r0, r1 + return r0 } -// interfaceVerificationMethod provides a mock function with given fields: _a0 -func (_m *Condition[T]) interfaceVerificationMethod(_a0 T) { +// InterfaceVerificationMethod provides a mock function with given fields: _a0 +func (_m *Condition[T]) InterfaceVerificationMethod(_a0 T) { _m.Called(_a0) } diff --git a/mocks/orm/DynamicOperator.go b/mocks/orm/DynamicOperator.go new file mode 100644 index 00000000..3615106a --- /dev/null +++ b/mocks/orm/DynamicOperator.go @@ -0,0 +1,82 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + orm "github.com/ditrit/badaas/orm" + mock "github.com/stretchr/testify/mock" +) + +// DynamicOperator is an autogenerated mock type for the DynamicOperator type +type DynamicOperator[T interface{}] struct { + mock.Mock +} + +// InterfaceVerificationMethod provides a mock function with given fields: _a0 +func (_m *DynamicOperator[T]) InterfaceVerificationMethod(_a0 T) { + _m.Called(_a0) +} + +// SelectJoin provides a mock function with given fields: valueNumber, joinNumber +func (_m *DynamicOperator[T]) SelectJoin(valueNumber uint, joinNumber uint) orm.DynamicOperator[T] { + ret := _m.Called(valueNumber, joinNumber) + + var r0 orm.DynamicOperator[T] + if rf, ok := ret.Get(0).(func(uint, uint) orm.DynamicOperator[T]); ok { + r0 = rf(valueNumber, joinNumber) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(orm.DynamicOperator[T]) + } + } + + return r0 +} + +// ToSQL provides a mock function with given fields: query, columnName +func (_m *DynamicOperator[T]) ToSQL(query *orm.Query, columnName string) (string, []interface{}, error) { + ret := _m.Called(query, columnName) + + var r0 string + var r1 []interface{} + var r2 error + if rf, ok := ret.Get(0).(func(*orm.Query, string) (string, []interface{}, error)); ok { + return rf(query, columnName) + } + if rf, ok := ret.Get(0).(func(*orm.Query, string) string); ok { + r0 = rf(query, columnName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(*orm.Query, string) []interface{}); ok { + r1 = rf(query, columnName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]interface{}) + } + } + + if rf, ok := ret.Get(2).(func(*orm.Query, string) error); ok { + r2 = rf(query, columnName) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +type mockConstructorTestingTNewDynamicOperator interface { + mock.TestingT + Cleanup(func()) +} + +// NewDynamicOperator creates a new instance of DynamicOperator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewDynamicOperator[T interface{}](t mockConstructorTestingTNewDynamicOperator) *DynamicOperator[T] { + mock := &DynamicOperator[T]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/orm/IJoinCondition.go b/mocks/orm/IJoinCondition.go index c1c4411f..e93d30c4 100644 --- a/mocks/orm/IJoinCondition.go +++ b/mocks/orm/IJoinCondition.go @@ -5,7 +5,6 @@ package mocks import ( orm "github.com/ditrit/badaas/orm" mock "github.com/stretchr/testify/mock" - gorm "gorm.io/gorm" ) // IJoinCondition is an autogenerated mock type for the IJoinCondition type @@ -14,33 +13,21 @@ type IJoinCondition[T orm.Model] struct { } // ApplyTo provides a mock function with given fields: query, table -func (_m *IJoinCondition[T]) ApplyTo(query *gorm.DB, table orm.Table) (*gorm.DB, error) { +func (_m *IJoinCondition[T]) ApplyTo(query *orm.Query, table orm.Table) error { ret := _m.Called(query, table) - var r0 *gorm.DB - var r1 error - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) (*gorm.DB, error)); ok { - return rf(query, table) - } - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) *gorm.DB); ok { + var r0 error + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) error); ok { r0 = rf(query, table) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gorm.DB) - } + r0 = ret.Error(0) } - if rf, ok := ret.Get(1).(func(*gorm.DB, orm.Table) error); ok { - r1 = rf(query, table) - } else { - r1 = ret.Error(1) - } - - return r0, r1 + return r0 } -// interfaceVerificationMethod provides a mock function with given fields: _a0 -func (_m *IJoinCondition[T]) interfaceVerificationMethod(_a0 T) { +// InterfaceVerificationMethod provides a mock function with given fields: _a0 +func (_m *IJoinCondition[T]) InterfaceVerificationMethod(_a0 T) { _m.Called(_a0) } diff --git a/mocks/orm/Operator.go b/mocks/orm/Operator.go index e2ae8183..f950024a 100644 --- a/mocks/orm/Operator.go +++ b/mocks/orm/Operator.go @@ -2,7 +2,10 @@ package mocks -import mock "github.com/stretchr/testify/mock" +import ( + orm "github.com/ditrit/badaas/orm" + mock "github.com/stretchr/testify/mock" +) // Operator is an autogenerated mock type for the Operator type type Operator[T interface{}] struct { @@ -14,32 +17,32 @@ func (_m *Operator[T]) InterfaceVerificationMethod(_a0 T) { _m.Called(_a0) } -// ToSQL provides a mock function with given fields: columnName -func (_m *Operator[T]) ToSQL(columnName string) (string, []interface{}, error) { - ret := _m.Called(columnName) +// ToSQL provides a mock function with given fields: query, columnName +func (_m *Operator[T]) ToSQL(query *orm.Query, columnName string) (string, []interface{}, error) { + ret := _m.Called(query, columnName) var r0 string var r1 []interface{} var r2 error - if rf, ok := ret.Get(0).(func(string) (string, []interface{}, error)); ok { - return rf(columnName) + if rf, ok := ret.Get(0).(func(*orm.Query, string) (string, []interface{}, error)); ok { + return rf(query, columnName) } - if rf, ok := ret.Get(0).(func(string) string); ok { - r0 = rf(columnName) + if rf, ok := ret.Get(0).(func(*orm.Query, string) string); ok { + r0 = rf(query, columnName) } else { r0 = ret.Get(0).(string) } - if rf, ok := ret.Get(1).(func(string) []interface{}); ok { - r1 = rf(columnName) + if rf, ok := ret.Get(1).(func(*orm.Query, string) []interface{}); ok { + r1 = rf(query, columnName) } else { if ret.Get(1) != nil { r1 = ret.Get(1).([]interface{}) } } - if rf, ok := ret.Get(2).(func(string) error); ok { - r2 = rf(columnName) + if rf, ok := ret.Get(2).(func(*orm.Query, string) error); ok { + r2 = rf(query, columnName) } else { r2 = ret.Error(2) } diff --git a/mocks/orm/WhereCondition.go b/mocks/orm/WhereCondition.go index 94eb0849..cc0ae5c4 100644 --- a/mocks/orm/WhereCondition.go +++ b/mocks/orm/WhereCondition.go @@ -5,7 +5,6 @@ package mocks import ( orm "github.com/ditrit/badaas/orm" mock "github.com/stretchr/testify/mock" - gorm "gorm.io/gorm" ) // WhereCondition is an autogenerated mock type for the WhereCondition type @@ -13,49 +12,51 @@ type WhereCondition[T orm.Model] struct { mock.Mock } -// ApplyTo provides a mock function with given fields: query, table -func (_m *WhereCondition[T]) ApplyTo(query *gorm.DB, table orm.Table) (*gorm.DB, error) { - ret := _m.Called(query, table) +// AffectsDeletedAt provides a mock function with given fields: +func (_m *WhereCondition[T]) AffectsDeletedAt() bool { + ret := _m.Called() - var r0 *gorm.DB - var r1 error - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) (*gorm.DB, error)); ok { - return rf(query, table) - } - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) *gorm.DB); ok { - r0 = rf(query, table) + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gorm.DB) - } + r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(*gorm.DB, orm.Table) error); ok { - r1 = rf(query, table) + return r0 +} + +// ApplyTo provides a mock function with given fields: query, table +func (_m *WhereCondition[T]) ApplyTo(query *orm.Query, table orm.Table) error { + ret := _m.Called(query, table) + + var r0 error + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) error); ok { + r0 = rf(query, table) } else { - r1 = ret.Error(1) + r0 = ret.Error(0) } - return r0, r1 + return r0 } // GetSQL provides a mock function with given fields: query, table -func (_m *WhereCondition[T]) GetSQL(query *gorm.DB, table orm.Table) (string, []interface{}, error) { +func (_m *WhereCondition[T]) GetSQL(query *orm.Query, table orm.Table) (string, []interface{}, error) { ret := _m.Called(query, table) var r0 string var r1 []interface{} var r2 error - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) (string, []interface{}, error)); ok { + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) (string, []interface{}, error)); ok { return rf(query, table) } - if rf, ok := ret.Get(0).(func(*gorm.DB, orm.Table) string); ok { + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) string); ok { r0 = rf(query, table) } else { r0 = ret.Get(0).(string) } - if rf, ok := ret.Get(1).(func(*gorm.DB, orm.Table) []interface{}); ok { + if rf, ok := ret.Get(1).(func(*orm.Query, orm.Table) []interface{}); ok { r1 = rf(query, table) } else { if ret.Get(1) != nil { @@ -63,7 +64,7 @@ func (_m *WhereCondition[T]) GetSQL(query *gorm.DB, table orm.Table) (string, [] } } - if rf, ok := ret.Get(2).(func(*gorm.DB, orm.Table) error); ok { + if rf, ok := ret.Get(2).(func(*orm.Query, orm.Table) error); ok { r2 = rf(query, table) } else { r2 = ret.Error(2) @@ -72,22 +73,8 @@ func (_m *WhereCondition[T]) GetSQL(query *gorm.DB, table orm.Table) (string, [] return r0, r1, r2 } -// affectsDeletedAt provides a mock function with given fields: -func (_m *WhereCondition[T]) affectsDeletedAt() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// interfaceVerificationMethod provides a mock function with given fields: _a0 -func (_m *WhereCondition[T]) interfaceVerificationMethod(_a0 T) { +// InterfaceVerificationMethod provides a mock function with given fields: _a0 +func (_m *WhereCondition[T]) InterfaceVerificationMethod(_a0 T) { _m.Called(_a0) } diff --git a/mocks/orm/iFieldIdentifier.go b/mocks/orm/iFieldIdentifier.go new file mode 100644 index 00000000..bf5ded50 --- /dev/null +++ b/mocks/orm/iFieldIdentifier.go @@ -0,0 +1,74 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + orm "github.com/ditrit/badaas/orm" + mock "github.com/stretchr/testify/mock" + + reflect "reflect" +) + +// iFieldIdentifier is an autogenerated mock type for the iFieldIdentifier type +type iFieldIdentifier struct { + mock.Mock +} + +// ColumnName provides a mock function with given fields: query, table +func (_m *iFieldIdentifier) ColumnName(query *orm.Query, table orm.Table) string { + ret := _m.Called(query, table) + + var r0 string + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) string); ok { + r0 = rf(query, table) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// ColumnSQL provides a mock function with given fields: query, table +func (_m *iFieldIdentifier) ColumnSQL(query *orm.Query, table orm.Table) string { + ret := _m.Called(query, table) + + var r0 string + if rf, ok := ret.Get(0).(func(*orm.Query, orm.Table) string); ok { + r0 = rf(query, table) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetModelType provides a mock function with given fields: +func (_m *iFieldIdentifier) GetModelType() reflect.Type { + ret := _m.Called() + + var r0 reflect.Type + if rf, ok := ret.Get(0).(func() reflect.Type); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(reflect.Type) + } + } + + return r0 +} + +type mockConstructorTestingTnewIFieldIdentifier interface { + mock.TestingT + Cleanup(func()) +} + +// newIFieldIdentifier creates a new instance of iFieldIdentifier. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func newIFieldIdentifier(t mockConstructorTestingTnewIFieldIdentifier) *iFieldIdentifier { + mock := &iFieldIdentifier{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}