Documentation ¶
Index ¶
- func AssertSQLNullBool(t *testing.T, in sql.NullBool, boolean *bool)
- func AssertSQLNullStringEqualTo(t *testing.T, in sql.NullString, text *string)
- func RowCount(totalCount int) *sqlmock.Rows
- func RowWhenObjectDoesNotExist() *sqlmock.Rows
- func RowWhenObjectExist() *sqlmock.Rows
- type DBMock
- type Mock
- type PageDetails
- type RepoCreateTestSuite
- type RepoDeleteTestSuite
- type RepoExistTestSuite
- type RepoGetTestSuite
- type RepoListPageableTestSuite
- type RepoListTestSuite
- type RepoUpdateTestSuite
- type RepoUpsertTestSuite
- type SQLQueryDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertSQLNullBool ¶
AssertSQLNullBool is a helper to check if the sql.NullBool is equal to the given bool.
func AssertSQLNullStringEqualTo ¶
func AssertSQLNullStringEqualTo(t *testing.T, in sql.NullString, text *string)
AssertSQLNullStringEqualTo is a helper to check if the sql.NullString is equal to the given string.
func RowCount ¶
func RowCount(totalCount int) *sqlmock.Rows
RowCount represents a sql row when count query is executed.
func RowWhenObjectDoesNotExist ¶
func RowWhenObjectDoesNotExist() *sqlmock.Rows
RowWhenObjectDoesNotExist represents a sql row when object does not exist.
func RowWhenObjectExist ¶
func RowWhenObjectExist() *sqlmock.Rows
RowWhenObjectExist represents a sql row when object exist.
Types ¶
type Mock ¶
type Mock interface { AssertExpectations(t mock.TestingT) bool On(methodName string, arguments ...interface{}) *mock.Call }
Mock represents a mockery Mock.
type PageDetails ¶
type PageDetails struct { ExpectedModelEntities []interface{} ExpectedDBEntities []interface{} ExpectedPage interface{} }
PageDetails represents the expected page returned from the List with paging operation. In case of dataloaders a single List operation can return array of pages - a page for each entity that is collected by the dataloader.
type RepoCreateTestSuite ¶
type RepoCreateTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} ModelEntity interface{} DBEntity interface{} NilModelEntity interface{} TenantID string DisableConverterErrorTest bool MethodName string IsTopLevelEntity bool IsGlobal bool }
RepoCreateTestSuite represents a generic test suite for repository Create method of any global entity or entity that has externally managed tenants in m2m table/view.
type RepoDeleteTestSuite ¶
type RepoDeleteTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} MethodName string MethodArgs []interface{} IsDeleteMany bool IsGlobal bool }
RepoDeleteTestSuite represents a generic test suite for repository Delete method of any global entity or entity that has externally managed tenants in m2m table/view.
type RepoExistTestSuite ¶
type RepoExistTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} TargetID string TenantID string RefEntity interface{} IsGlobal bool MethodName string MethodArgs []interface{} }
RepoExistTestSuite represents a generic test suite for repository Exists method of any entity that has externally managed tenants in m2m table/view. This test suite is not suitable for global entities or entities with embedded tenant in them.
type RepoGetTestSuite ¶
type RepoGetTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} ExpectedModelEntity interface{} ExpectedDBEntity interface{} MethodArgs []interface{} AdditionalConverterArgs []interface{} DisableConverterErrorTest bool MethodName string ExpectNotFoundError bool AfterNotFoundErrorSQLQueryDetails []SQLQueryDetails AfterNotFoundErrorExpectedModelEntity interface{} AfterNotFoundErrorExpectedDBEntity interface{} }
RepoGetTestSuite represents a generic test suite for repository Get method of any global entity or entity that has externally managed tenants in m2m table/view. This test suite is not suitable entities with embedded tenant in them.
type RepoListPageableTestSuite ¶
type RepoListPageableTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} AdditionalConverterArgs []interface{} Pages []PageDetails MethodArgs []interface{} DisableConverterErrorTest bool MethodName string }
RepoListPageableTestSuite represents a generic test suite for repository List with paging methods of any entity that has externally managed tenants in m2m table/view. This test suite is not suitable for global entities or entities with embedded tenant in them.
type RepoListTestSuite ¶
type RepoListTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock ShouldSkipMockFromEntity bool RepoConstructorFunc interface{} ExpectedModelEntities []interface{} ExpectedDBEntities []interface{} MethodArgs []interface{} AdditionalConverterArgs []interface{} DisableConverterErrorTest bool MethodName string DisableEmptySliceTest bool Context context.Context }
RepoListTestSuite represents a generic test suite for repository List without paging method of any global entity or entity that has externally managed tenants in m2m table/view.
type RepoUpdateTestSuite ¶
type RepoUpdateTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} ModelEntity interface{} DBEntity interface{} NilModelEntity interface{} TenantID string DisableConverterErrorTest bool UpdateMethodName string IsGlobal bool }
RepoUpdateTestSuite represents a generic test suite for repository Update and UpdateWithVersion methods of any global entity or entity that has externally managed tenants in m2m table/view.
type RepoUpsertTestSuite ¶
type RepoUpsertTestSuite struct { Name string SQLQueryDetails []SQLQueryDetails ConverterMockProvider func() Mock RepoConstructorFunc interface{} ModelEntity interface{} DBEntity interface{} NilModelEntity interface{} TenantID string DisableConverterErrorTest bool UpsertMethodName string }
RepoUpsertTestSuite represents a generic test suite for repository Upsert, TrustedUpsert and UpsertGlobal methods of any entity that has externally managed tenants in m2m table/view. This test suite is not suitable for global entities or entities with embedded tenant in them.
type SQLQueryDetails ¶
type SQLQueryDetails struct { Query string IsSelect bool Args []driver.Value ValidResult driver.Result InvalidResult driver.Result ValidRowsProvider func() []*sqlmock.Rows InvalidRowsProvider func() []*sqlmock.Rows SkipFailValidation bool }
SQLQueryDetails represent an SQL expected query details to provide to the DB mock.