Skip to content

reltest

import "github.com/go-rel/reltest"

Overview

Package reltest for unit testing database interaction.

Variables

var Any any = anyValue{}
var (
    // ErrConnectionClosed is alias for sql.ErrConnDone.
    ErrConnectionClosed = sql.ErrConnDone
)

type Assert

type Assert struct {
    // contains filtered or unexported fields
}

func (*Assert) Many

func (a *Assert) Many()
Many set max calls to unlimited times.

func (*Assert) Maybe

func (a *Assert) Maybe()
Maybe allow calls to be skipped.

func (*Assert) Once

func (a *Assert) Once()
Once set max calls to one time.

func (*Assert) Times

func (a *Assert) Times(times int)
Times set number of allowed calls.

func (*Assert) Twice

func (a *Assert) Twice()
Twice set max calls to two times.

type EntityMockDelete

type EntityMockDelete[T any] struct {
    *MockDelete
}
EntityMockDelete mock wrapper

func (*EntityMockDelete[T]) For

func (emd *EntityMockDelete[T]) For(result *T) *EntityMockDelete[T]
For assert calls for given entity.

type EntityMockDeleteAll

type EntityMockDeleteAll[T any] struct {
    *MockDeleteAll
}
EntityMockDeleteAll mock wrapper

func (*EntityMockDeleteAll[T]) For

func (emda *EntityMockDeleteAll[T]) For(result *[]T) *EntityMockDeleteAll[T]
For assert calls for given entity.

type EntityMockFind

type EntityMockFind[T any] struct {
    *MockFind
}
EntityMockFind mock wrapper

func (*EntityMockFind[T]) Result

func (emf *EntityMockFind[T]) Result(result T) *Assert
Result sets the result of this query.

type EntityMockFindAll

type EntityMockFindAll[T any] struct {
    *MockFindAll
}
EntityMockFindAll mock wrapper

func (*EntityMockFindAll[T]) Result

func (emfa *EntityMockFindAll[T]) Result(result []T) *Assert
Result sets the result of this query.

type EntityMockFindAndCountAll

type EntityMockFindAndCountAll[T any] struct {
    *MockFindAndCountAll
}
EntityMockFindAndCountAll mock wrapper

func (*EntityMockFindAndCountAll[T]) Result

func (emfaca *EntityMockFindAndCountAll[T]) Result(result []T, count int) *Assert
Result sets the result of this query.

type EntityMockInsertAll

type EntityMockInsertAll[T any] struct {
    *MockInsertAll
}
EntityMockInsertAll mock wrapper

func (*EntityMockInsertAll[T]) For

func (emia *EntityMockInsertAll[T]) For(result *[]T) *EntityMockInsertAll[T]
For assert calls for given entity.

type EntityMockIterate

type EntityMockIterate[T any] struct {
    *MockIterate
}
EntityMockIterate mock wrapper

func (*EntityMockIterate[T]) Result

func (emi *EntityMockIterate[T]) Result(result []T) *Assert
Result sets the result of preload.

type EntityMockMutate

type EntityMockMutate[T any] struct {
    *MockMutate
}
EntityMockMutate mock wrapper

func (*EntityMockMutate[T]) For

func (emm *EntityMockMutate[T]) For(result *T) *EntityMockMutate[T]
Result sets the result of this query.

type EntityMockPreload

type EntityMockPreload[T any] struct {
    *MockPreload
}
EntityMockPreload mock wrapper

func (*EntityMockPreload[T]) For

func (emp *EntityMockPreload[T]) For(result *T) *EntityMockPreload[T]
For assert calls for given entity.

type EntityMockPreloadAll

type EntityMockPreloadAll[T any] struct {
    *MockPreload
}
EntityMockPreloadAll mock wrapper

func (*EntityMockPreloadAll[T]) For

func (empa *EntityMockPreloadAll[T]) For(result *[]T) *EntityMockPreloadAll[T]
For assert calls for given entity.

type EntityRepository

type EntityRepository[T any] struct {
    rel.EntityRepository[T]
    // contains filtered or unexported fields
}
EntityRepository mock

func NewEntityRepository

func NewEntityRepository[T any]() *EntityRepository[T]

func (*EntityRepository[T]) AssertExpectations

func (er *EntityRepository[T]) AssertExpectations(t TestingT) bool
AssertExpectations asserts that everything was in fact called as expected. Calls may have occurred in any order.

func (*EntityRepository[T]) ExpectAggregate

func (er *EntityRepository[T]) ExpectAggregate(query rel.Query, aggregate string, field string) *MockAggregate
ExpectAggregate apply mocks and expectations for Aggregate

func (*EntityRepository[T]) ExpectCount

func (er *EntityRepository[T]) ExpectCount(collection string, queriers ...rel.Querier) *MockCount
ExpectCount apply mocks and expectations for Count

func (*EntityRepository[T]) ExpectDelete

func (er *EntityRepository[T]) ExpectDelete(options ...rel.Mutator) *EntityMockDelete[T]
ExpectDelete apply mocks and expectations for Delete

func (*EntityRepository[T]) ExpectDeleteAll

func (er *EntityRepository[T]) ExpectDeleteAll() *EntityMockDeleteAll[T]
ExpectDeleteAll apply mocks and expectations for DeleteAll

func (*EntityRepository[T]) ExpectFind

func (er *EntityRepository[T]) ExpectFind(queriers ...rel.Querier) *EntityMockFind[T]
ExpectFind apply mocks and expectations for Find

func (*EntityRepository[T]) ExpectFindAll

func (er *EntityRepository[T]) ExpectFindAll(queriers ...rel.Querier) *EntityMockFindAll[T]
ExpectFindAll apply mocks and expectations for FindAll

func (*EntityRepository[T]) ExpectFindAndCountAll

func (er *EntityRepository[T]) ExpectFindAndCountAll(queriers ...rel.Querier) *EntityMockFindAndCountAll[T]
ExpectFindAndCountAll apply mocks and expectations for FindAndCountAll

func (*EntityRepository[T]) ExpectInsert

func (er *EntityRepository[T]) ExpectInsert(mutators ...rel.Mutator) *EntityMockMutate[T]
ExpectInsert apply mocks and expectations for Insert

func (*EntityRepository[T]) ExpectInsertAll

func (er *EntityRepository[T]) ExpectInsertAll() *EntityMockInsertAll[T]
ExpectInsertAll entities.

func (*EntityRepository[T]) ExpectIterate

func (er *EntityRepository[T]) ExpectIterate(query rel.Query, options ...rel.IteratorOption) *EntityMockIterate[T]
ExpectIterate apply mocks and expectations for Iterate

func (*EntityRepository[T]) ExpectPreload

func (er *EntityRepository[T]) ExpectPreload(field string, queriers ...rel.Querier) *EntityMockPreload[T]
ExpectPreload apply mocks and expectations for Preload

func (*EntityRepository[T]) ExpectPreloadAll

func (er *EntityRepository[T]) ExpectPreloadAll(field string, queriers ...rel.Querier) *EntityMockPreloadAll[T]
ExpectPreload apply mocks and expectations for Preload

func (*EntityRepository[T]) ExpectTransaction

func (er *EntityRepository[T]) ExpectTransaction(fn func(*Repository))
ExpectTransaction declare expectation inside transaction.

func (*EntityRepository[T]) ExpectUpdate

func (er *EntityRepository[T]) ExpectUpdate(mutators ...rel.Mutator) *EntityMockMutate[T]
ExpectUpdate apply mocks and expectations for Update

func (*EntityRepository[T]) WrapTransaction

func (er *EntityRepository[T]) WrapTransaction(repository *Repository) *EntityRepository[T]
WrapTransaction repository

type MockAggregate

type MockAggregate struct {
    // contains filtered or unexported fields
}
MockAggregate asserts and simulate UpdateAny function for test.

func (*MockAggregate) ConnectionClosed

func (ma *MockAggregate) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockAggregate) Error

func (ma *MockAggregate) Error(err error) *Assert
Error sets error to be returned.

func (MockAggregate) ExpectString

func (ma MockAggregate) ExpectString() string
ExpectString representation of mocked call.

func (*MockAggregate) Result

func (ma *MockAggregate) Result(count int) *Assert
Result sets the result of this query.

func (MockAggregate) String

func (ma MockAggregate) String() string
String representation of mocked call.

type MockCount

type MockCount struct {
    // contains filtered or unexported fields
}
MockCount asserts and simulate UpdateAny function for test.

func (*MockCount) ConnectionClosed

func (mc *MockCount) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockCount) Error

func (mc *MockCount) Error(err error) *Assert
Error sets error to be returned.

func (MockCount) ExpectString

func (mc MockCount) ExpectString() string
ExpectString representation of mocked call.

func (*MockCount) Result

func (mc *MockCount) Result(count int) *Assert
Result sets the result of this query.

func (MockCount) String

func (mc MockCount) String() string
String representation of mocked call.

type MockDelete

type MockDelete struct {
    // contains filtered or unexported fields
}
MockDelete asserts and simulate Delete function for test.

func (*MockDelete) ConnectionClosed

func (md *MockDelete) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockDelete) Error

func (md *MockDelete) Error(err error) *Assert
Error sets error to be returned.

func (MockDelete) ExpectString

func (md MockDelete) ExpectString() string
ExpectString representation of mocked call.

func (*MockDelete) For

func (md *MockDelete) For(entity any) *MockDelete
For assert calls for given entity.

func (*MockDelete) ForContains

func (md *MockDelete) ForContains(contains any) *MockDelete
ForContains assert calls to contains some value of given struct.

func (*MockDelete) ForTable

func (md *MockDelete) ForTable(typ string) *MockDelete
ForTable assert calls for given table.

func (*MockDelete) ForType

func (md *MockDelete) ForType(typ string) *MockDelete
ForType assert calls for given type. Type must include package name, example: model.User.

func (MockDelete) String

func (md MockDelete) String() string
String representation of mocked call.

func (*MockDelete) Success

func (md *MockDelete) Success() *Assert
Success sets no error to be returned.

type MockDeleteAll

type MockDeleteAll struct {
    // contains filtered or unexported fields
}
MockDeleteAll asserts and simulate Delete function for test.

func (*MockDeleteAll) ConnectionClosed

func (mda *MockDeleteAll) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockDeleteAll) Error

func (mda *MockDeleteAll) Error(err error) *Assert
Error sets error to be returned.

func (MockDeleteAll) ExpectString

func (mda MockDeleteAll) ExpectString() string
ExpectString representation of mocked call.

func (*MockDeleteAll) For

func (mda *MockDeleteAll) For(entity any) *MockDeleteAll
For assert calls for given entity.

func (*MockDeleteAll) ForTable

func (mda *MockDeleteAll) ForTable(typ string) *MockDeleteAll
ForTable assert calls for given table.

func (*MockDeleteAll) ForType

func (mda *MockDeleteAll) ForType(typ string) *MockDeleteAll
ForType assert calls for given type. Type must include package name, example: model.User.

func (MockDeleteAll) String

func (mda MockDeleteAll) String() string
String representation of mocked call.

func (*MockDeleteAll) Success

func (mda *MockDeleteAll) Success() *Assert
Success sets no error to be returned.

type MockDeleteAny

type MockDeleteAny struct {
    // contains filtered or unexported fields
}
MockDeleteAny asserts and simulate DeleteAny function for test.

func (*MockDeleteAny) ConnectionClosed

func (mda *MockDeleteAny) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockDeleteAny) DeletedCount

func (mda *MockDeleteAny) DeletedCount(deletedCount int) *Assert
DeletedCount set the returned deleted count of this function.

func (*MockDeleteAny) Error

func (mda *MockDeleteAny) Error(err error) *Assert
Error sets error to be returned.

func (MockDeleteAny) ExpectString

func (mda MockDeleteAny) ExpectString() string
ExpectString representation of mocked call.

func (MockDeleteAny) String

func (mda MockDeleteAny) String() string
String representation of mocked call.

func (*MockDeleteAny) Success

func (mda *MockDeleteAny) Success() *Assert
Success sets no error to be returned.

func (*MockDeleteAny) Unsafe

func (mda *MockDeleteAny) Unsafe() *MockDeleteAny
Unsafe allows for unsafe operation to delete entities without where condition.

type MockExec

type MockExec struct {
    // contains filtered or unexported fields
}
MockExec asserts and simulate UpdateAny function for test.

func (*MockExec) ConnectionClosed

func (me *MockExec) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockExec) Error

func (me *MockExec) Error(err error) *Assert
Error sets error to be returned.

func (MockExec) ExpectString

func (me MockExec) ExpectString() string
ExpectString representation of mocked call.

func (*MockExec) Result

func (me *MockExec) Result(lastInsertedId int, rowsAffected int) *Assert
Result sets the result of this query.

func (MockExec) String

func (me MockExec) String() string
String representation of mocked call.

type MockFind

type MockFind struct {
    // contains filtered or unexported fields
}
MockFind asserts and simulate find function for test.

func (*MockFind) ConnectionClosed

func (mf *MockFind) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockFind) Error

func (mf *MockFind) Error(err error) *Assert
Error sets error to be returned.

func (MockFind) ExpectString

func (mf MockFind) ExpectString() string
ExpectString representation of mocked call.

func (*MockFind) NotFound

func (mf *MockFind) NotFound() *Assert
NotFound sets NotFoundError to be returned.

func (*MockFind) Result

func (mf *MockFind) Result(result any) *Assert
Result sets the result of this query.

func (MockFind) String

func (mf MockFind) String() string
String representation of mocked call.

type MockFindAll

type MockFindAll struct {
    // contains filtered or unexported fields
}
MockFindAll asserts and simulate find all function for test.

func (*MockFindAll) ConnectionClosed

func (mfa *MockFindAll) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockFindAll) Error

func (mfa *MockFindAll) Error(err error) *Assert
Error sets error to be returned.

func (MockFindAll) ExpectString

func (mfa MockFindAll) ExpectString() string
ExpectString representation of mocked call.

func (*MockFindAll) Result

func (mfa *MockFindAll) Result(result any) *Assert
Result sets the result of this query.

func (MockFindAll) String

func (mfa MockFindAll) String() string
String representation of mocked call.

type MockFindAndCountAll

type MockFindAndCountAll struct {
    // contains filtered or unexported fields
}
MockFindAndCountAll asserts and simulate find and count all function for test.

func (*MockFindAndCountAll) ConnectionClosed

func (mfca *MockFindAndCountAll) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockFindAndCountAll) Error

func (mfca *MockFindAndCountAll) Error(err error) *Assert
Error sets error to be returned.

func (MockFindAndCountAll) ExpectString

func (mfca MockFindAndCountAll) ExpectString() string
ExpectString representation of mocked call.

func (*MockFindAndCountAll) Result

func (mfca *MockFindAndCountAll) Result(result any, count int) *Assert
Result sets the result of this query.

func (MockFindAndCountAll) String

func (mfca MockFindAndCountAll) String() string
String representation of mocked call.

type MockInsertAll

type MockInsertAll struct {
    // contains filtered or unexported fields
}
MockInsertAll asserts and simulate Insert function for test.

func (*MockInsertAll) ConnectionClosed

func (mia *MockInsertAll) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockInsertAll) Error

func (mia *MockInsertAll) Error(err error) *Assert
Error sets error to be returned.

func (MockInsertAll) ExpectString

func (mia MockInsertAll) ExpectString() string
ExpectString representation of mocked call.

func (*MockInsertAll) For

func (mia *MockInsertAll) For(entity any) *MockInsertAll
For assert calls for given entity.

func (*MockInsertAll) ForTable

func (mia *MockInsertAll) ForTable(typ string) *MockInsertAll
ForTable assert calls for given table.

func (*MockInsertAll) ForType

func (mia *MockInsertAll) ForType(typ string) *MockInsertAll
ForType assert calls for given type. Type must include package name, example: model.User.

func (*MockInsertAll) NotUnique

func (mia *MockInsertAll) NotUnique(key string) *Assert
NotUnique sets not unique error to be returned.

func (MockInsertAll) String

func (mia MockInsertAll) String() string
String representation of mocked call.

func (*MockInsertAll) Success

func (mia *MockInsertAll) Success() *Assert
Success sets no error to be returned.

type MockIterate

type MockIterate struct {
    // contains filtered or unexported fields
}
MockIterate asserts and simulate Delete function for test.

func (MockIterate) Close

func (mi MockIterate) Close() error
Close iterator.

func (*MockIterate) ConnectionClosed

func (mi *MockIterate) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockIterate) Error

func (mi *MockIterate) Error(err error) *Assert
Error sets error to be returned.

func (MockIterate) ExpectString

func (mi MockIterate) ExpectString() string
ExpectString representation of mocked call.

func (*MockIterate) Next

func (mi *MockIterate) Next(entity any) error
Next return next entity in iterator.

func (*MockIterate) Result

func (mi *MockIterate) Result(result any) *Assert
Result sets the result of preload.

func (MockIterate) String

func (mi MockIterate) String() string
String representation of mocked call.

type MockMutate

type MockMutate struct {
    // contains filtered or unexported fields
}
MockMutate asserts and simulate Insert function for test.

func (*MockMutate) ConnectionClosed

func (mm *MockMutate) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockMutate) Error

func (mm *MockMutate) Error(err error) *Assert
Error sets error to be returned.

func (MockMutate) ExpectString

func (mm MockMutate) ExpectString() string
ExpectString representation of mocked call.

func (*MockMutate) For

func (mm *MockMutate) For(entity any) *MockMutate
For assert calls for given entity.

func (*MockMutate) ForContains

func (mm *MockMutate) ForContains(contains any) *MockMutate
ForContains assert calls to contains some value of given struct.

func (*MockMutate) ForTable

func (mm *MockMutate) ForTable(typ string) *MockMutate
ForTable assert calls for given table.

func (*MockMutate) ForType

func (mm *MockMutate) ForType(typ string) *MockMutate
ForType assert calls for given type. Type must include package name, example: model.User.

func (*MockMutate) NotUnique

func (mm *MockMutate) NotUnique(key string) *Assert
NotUnique sets not unique error to be returned.

func (MockMutate) String

func (mm MockMutate) String() string
String representation of mocked call.

func (*MockMutate) Success

func (mm *MockMutate) Success() *Assert
Success sets no error to be returned.

type MockPreload

type MockPreload struct {
    // contains filtered or unexported fields
}
MockPreload asserts and simulate Delete function for test.

func (*MockPreload) ConnectionClosed

func (mp *MockPreload) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockPreload) Error

func (mp *MockPreload) Error(err error) *Assert
Error sets error to be returned.

func (MockPreload) ExpectString

func (mp MockPreload) ExpectString() string
ExpectString representation of mocked call.

func (*MockPreload) For

func (md *MockPreload) For(entities any) *MockPreload
For assert calls for given entity.

func (*MockPreload) ForType

func (md *MockPreload) ForType(typ string) *MockPreload
ForType assert calls for given type. Type must include package name, example: model.User.

func (*MockPreload) Result

func (mp *MockPreload) Result(result any) *Assert
Result sets the result of preload.

func (MockPreload) String

func (mp MockPreload) String() string
String representation of mocked call.

type MockUpdateAny

type MockUpdateAny struct {
    // contains filtered or unexported fields
}
MockUpdateAny asserts and simulate UpdateAny function for test.

func (*MockUpdateAny) ConnectionClosed

func (mua *MockUpdateAny) ConnectionClosed() *Assert
ConnectionClosed sets this error to be returned.

func (*MockUpdateAny) Error

func (mua *MockUpdateAny) Error(err error) *Assert
Error sets error to be returned.

func (MockUpdateAny) ExpectString

func (mua MockUpdateAny) ExpectString() string
ExpectString representation of mocked call.

func (MockUpdateAny) String

func (mua MockUpdateAny) String() string
String representation of mocked call.

func (*MockUpdateAny) Unsafe

func (mua *MockUpdateAny) Unsafe() *MockUpdateAny
Unsafe allows for unsafe operation to delete entities without where condition.

func (*MockUpdateAny) UpdatedCount

func (mua *MockUpdateAny) UpdatedCount(updatedCount int) *Assert
UpdatedCount set the returned deleted count of this function.

type Repository

type Repository struct {
    // contains filtered or unexported fields
}
Repository mock

func New

func New() *Repository
New test repository.

func (*Repository) Adapter

func (r *Repository) Adapter(ctx context.Context) rel.Adapter
Adapter provides a mock function with given fields:

func (*Repository) Aggregate

func (r *Repository) Aggregate(ctx context.Context, query rel.Query, aggregate string, field string) (int, error)
Aggregate provides a mock function with given fields: query, aggregate, field

func (*Repository) AssertExpectations

func (r *Repository) AssertExpectations(t TestingT) bool
AssertExpectations asserts that everything was in fact called as expected. Calls may have occurred in any order.

func (*Repository) Count

func (r *Repository) Count(ctx context.Context, collection string, queriers ...rel.Querier) (int, error)
Count provides a mock function with given fields: collection, queriers

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, entity any, options ...rel.Mutator) error
Delete provides a mock function with given fields: entity

func (*Repository) DeleteAll

func (r *Repository) DeleteAll(ctx context.Context, entities any) error
DeleteAll provides DeleteAll mock function with given fields: entities

func (*Repository) DeleteAny

func (r *Repository) DeleteAny(ctx context.Context, query rel.Query) (int, error)
DeleteAny provides a mock function with given fields: query

func (*Repository) Exec

func (r *Repository) Exec(ctx context.Context, statement string, args ...any) (int, int, error)
Exec raw statement. Returns last inserted id, rows affected and error.

func (*Repository) ExpectAggregate

func (r *Repository) ExpectAggregate(query rel.Query, aggregate string, field string) *MockAggregate
ExpectAggregate apply mocks and expectations for Aggregate

func (*Repository) ExpectCount

func (r *Repository) ExpectCount(collection string, queriers ...rel.Querier) *MockCount
ExpectCount apply mocks and expectations for Count

func (*Repository) ExpectDelete

func (r *Repository) ExpectDelete(options ...rel.Mutator) *MockDelete
ExpectDelete apply mocks and expectations for Delete

func (*Repository) ExpectDeleteAll

func (r *Repository) ExpectDeleteAll() *MockDeleteAll
ExpectDeleteAll apply mocks and expectations for DeleteAll

func (*Repository) ExpectDeleteAny

func (r *Repository) ExpectDeleteAny(query rel.Query) *MockDeleteAny
ExpectDeleteAny apply mocks and expectations for DeleteAny

func (*Repository) ExpectExec

func (r *Repository) ExpectExec(statement string, args ...any) *MockExec
ExpectExec for mocking Exec

func (*Repository) ExpectFind

func (r *Repository) ExpectFind(queriers ...rel.Querier) *MockFind
ExpectFind apply mocks and expectations for Find

func (*Repository) ExpectFindAll

func (r *Repository) ExpectFindAll(queriers ...rel.Querier) *MockFindAll
ExpectFindAll apply mocks and expectations for FindAll

func (*Repository) ExpectFindAndCountAll

func (r *Repository) ExpectFindAndCountAll(queriers ...rel.Querier) *MockFindAndCountAll
ExpectFindAndCountAll apply mocks and expectations for FindAndCountAll

func (*Repository) ExpectInsert

func (r *Repository) ExpectInsert(mutators ...rel.Mutator) *MockMutate
ExpectInsert apply mocks and expectations for Insert

func (*Repository) ExpectInsertAll

func (r *Repository) ExpectInsertAll() *MockInsertAll
ExpectInsertAll entities.

func (*Repository) ExpectIterate

func (r *Repository) ExpectIterate(query rel.Query, options ...rel.IteratorOption) *MockIterate
ExpectIterate apply mocks and expectations for Iterate

func (*Repository) ExpectPreload

func (r *Repository) ExpectPreload(field string, queriers ...rel.Querier) *MockPreload
ExpectPreload apply mocks and expectations for Preload

func (*Repository) ExpectTransaction

func (r *Repository) ExpectTransaction(fn func(*Repository))
ExpectTransaction declare expectation inside transaction.

func (*Repository) ExpectUpdate

func (r *Repository) ExpectUpdate(mutators ...rel.Mutator) *MockMutate
ExpectUpdate apply mocks and expectations for Update

func (*Repository) ExpectUpdateAny

func (r *Repository) ExpectUpdateAny(query rel.Query, mutates ...rel.Mutate) *MockUpdateAny
ExpectUpdateAny apply mocks and expectations for UpdateAny

func (*Repository) Find

func (r *Repository) Find(ctx context.Context, entity any, queriers ...rel.Querier) error
Find provides a mock function with given fields: entity, queriers

func (*Repository) FindAll

func (r *Repository) FindAll(ctx context.Context, entities any, queriers ...rel.Querier) error
FindAll provides a mock function with given fields: entities, queriers

func (*Repository) FindAndCountAll

func (r *Repository) FindAndCountAll(ctx context.Context, entities any, queriers ...rel.Querier) (int, error)
FindAndCountAll provides a mock function with given fields: entities, queriers

func (*Repository) Insert

func (r *Repository) Insert(ctx context.Context, entity any, mutators ...rel.Mutator) error
Insert provides a mock function with given fields: entity, mutators

func (*Repository) InsertAll

func (r *Repository) InsertAll(ctx context.Context, entities any, mutators ...rel.Mutator) error
InsertAll entities.

func (*Repository) Instrumentation

func (r *Repository) Instrumentation(instrumenter rel.Instrumenter)
Instrumentation provides a mock function with given fields: instrumenter

func (*Repository) Iterate

func (r *Repository) Iterate(ctx context.Context, query rel.Query, options ...rel.IteratorOption) rel.Iterator
Iterate through a collection of entities from database in batches. This function returns iterator that can be used to loop all entities. Limit, Offset and Sort query is automatically ignored.

func (*Repository) MustAggregate

func (r *Repository) MustAggregate(ctx context.Context, query rel.Query, aggregate string, field string) int
MustAggregate provides a mock function with given fields: query, aggregate, field

func (*Repository) MustCount

func (r *Repository) MustCount(ctx context.Context, collection string, queriers ...rel.Querier) int
MustCount provides a mock function with given fields: collection, queriers

func (*Repository) MustDelete

func (r *Repository) MustDelete(ctx context.Context, entity any, options ...rel.Mutator)
MustDelete provides a mock function with given fields: entity

func (*Repository) MustDeleteAll

func (r *Repository) MustDeleteAll(ctx context.Context, entity any)
MustDeleteAll provides a mock function with given fields: entity

func (*Repository) MustDeleteAny

func (r *Repository) MustDeleteAny(ctx context.Context, query rel.Query) int
MustDeleteAny provides a mock function with given fields: query

func (*Repository) MustExec

func (r *Repository) MustExec(ctx context.Context, statement string, args ...any) (int, int)
MustExec raw statement. Returns last inserted id, rows affected and error.

func (*Repository) MustFind

func (r *Repository) MustFind(ctx context.Context, entity any, queriers ...rel.Querier)
MustFind provides a mock function with given fields: entity, queriers

func (*Repository) MustFindAll

func (r *Repository) MustFindAll(ctx context.Context, entities any, queriers ...rel.Querier)
MustFindAll provides a mock function with given fields: entities, queriers

func (*Repository) MustFindAndCountAll

func (r *Repository) MustFindAndCountAll(ctx context.Context, entities any, queriers ...rel.Querier) int
MustFindAndCountAll provides a mock function with given fields: entities, queriers

func (*Repository) MustInsert

func (r *Repository) MustInsert(ctx context.Context, entity any, mutators ...rel.Mutator)
MustInsert provides a mock function with given fields: entity, mutators

func (*Repository) MustInsertAll

func (r *Repository) MustInsertAll(ctx context.Context, entities any, mutators ...rel.Mutator)
MustInsertAll entities.

func (*Repository) MustPreload

func (r *Repository) MustPreload(ctx context.Context, entities any, field string, queriers ...rel.Querier)
MustPreload provides a mock function with given fields: entities, field, queriers

func (*Repository) MustUpdate

func (r *Repository) MustUpdate(ctx context.Context, entity any, mutators ...rel.Mutator)
MustUpdate provides a mock function with given fields: entity, mutators

func (*Repository) MustUpdateAny

func (r *Repository) MustUpdateAny(ctx context.Context, query rel.Query, mutates ...rel.Mutate) int
MustUpdateAny provides a mock function with given fields: query

func (*Repository) Ping

func (r *Repository) Ping(ctx context.Context) error
Ping database.

func (*Repository) Preload

func (r *Repository) Preload(ctx context.Context, entities any, field string, queriers ...rel.Querier) error
Preload provides a mock function with given fields: entities, field, queriers

func (*Repository) Transaction

func (r *Repository) Transaction(ctx context.Context, fn func(ctx context.Context) error) error
Transaction provides a mock function with given fields: fn

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, entity any, mutators ...rel.Mutator) error
Update provides a mock function with given fields: entity, mutators

func (*Repository) UpdateAny

func (r *Repository) UpdateAny(ctx context.Context, query rel.Query, mutates ...rel.Mutate) (int, error)
UpdateAny provides a mock function with given fields: query

type TestingT

type TestingT interface {
    Logf(format string, args ...any)
    Errorf(format string, args ...any)
    Helper()
}
TestingT is an interface wrapper around *testing.T


Last update: 2024-12-19