From 13ec30849523ba78e6930678113ce258c8f0e896 Mon Sep 17 00:00:00 2001 From: Franco Liberali Date: Wed, 2 Aug 2023 16:37:22 +0200 Subject: [PATCH] create mocks for new types --- mocks/orm/Operator.go | 63 +++++++++++++++++++++ mocks/orm/WhereCondition.go | 106 ++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 mocks/orm/Operator.go create mode 100644 mocks/orm/WhereCondition.go diff --git a/mocks/orm/Operator.go b/mocks/orm/Operator.go new file mode 100644 index 00000000..e2ae8183 --- /dev/null +++ b/mocks/orm/Operator.go @@ -0,0 +1,63 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Operator is an autogenerated mock type for the Operator type +type Operator[T interface{}] struct { + mock.Mock +} + +// InterfaceVerificationMethod provides a mock function with given fields: _a0 +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) + + 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(string) string); ok { + r0 = rf(columnName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) []interface{}); ok { + r1 = rf(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) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +type mockConstructorTestingTNewOperator interface { + mock.TestingT + Cleanup(func()) +} + +// NewOperator creates a new instance of Operator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewOperator[T interface{}](t mockConstructorTestingTNewOperator) *Operator[T] { + mock := &Operator[T]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/orm/WhereCondition.go b/mocks/orm/WhereCondition.go new file mode 100644 index 00000000..725d3ef3 --- /dev/null +++ b/mocks/orm/WhereCondition.go @@ -0,0 +1,106 @@ +// Code generated by mockery v2.20.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + gorm "gorm.io/gorm" +) + +// WhereCondition is an autogenerated mock type for the WhereCondition type +type WhereCondition[T interface{}] struct { + mock.Mock +} + +// ApplyTo provides a mock function with given fields: query, tableName +func (_m *WhereCondition[T]) ApplyTo(query *gorm.DB, tableName string) (*gorm.DB, error) { + ret := _m.Called(query, tableName) + + var r0 *gorm.DB + var r1 error + if rf, ok := ret.Get(0).(func(*gorm.DB, string) (*gorm.DB, error)); ok { + return rf(query, tableName) + } + if rf, ok := ret.Get(0).(func(*gorm.DB, string) *gorm.DB); ok { + r0 = rf(query, tableName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*gorm.DB) + } + } + + if rf, ok := ret.Get(1).(func(*gorm.DB, string) error); ok { + r1 = rf(query, tableName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetSQL provides a mock function with given fields: query, tableName +func (_m *WhereCondition[T]) GetSQL(query *gorm.DB, tableName string) (string, []interface{}, error) { + ret := _m.Called(query, tableName) + + var r0 string + var r1 []interface{} + var r2 error + if rf, ok := ret.Get(0).(func(*gorm.DB, string) (string, []interface{}, error)); ok { + return rf(query, tableName) + } + if rf, ok := ret.Get(0).(func(*gorm.DB, string) string); ok { + r0 = rf(query, tableName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(*gorm.DB, string) []interface{}); ok { + r1 = rf(query, tableName) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]interface{}) + } + } + + if rf, ok := ret.Get(2).(func(*gorm.DB, string) error); ok { + r2 = rf(query, tableName) + } else { + r2 = ret.Error(2) + } + + 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) { + _m.Called(_a0) +} + +type mockConstructorTestingTNewWhereCondition interface { + mock.TestingT + Cleanup(func()) +} + +// NewWhereCondition creates a new instance of WhereCondition. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewWhereCondition[T interface{}](t mockConstructorTestingTNewWhereCondition) *WhereCondition[T] { + mock := &WhereCondition[T]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}