Documentation ¶
Overview ¶
Package reltest for unit testing database interaction.
Example ¶
package main import ( "context" "fmt" "github.com/go-rel/rel/where" "github.com/go-rel/reltest" ) type Movie struct { ID int Title string } func main() { var ( repo = reltest.New() ) // Mock query repo.ExpectFind(where.Eq("id", 1)).Result(Movie{ID: 1, Title: "Golang"}) var movie Movie repo.MustFind(context.Background(), &movie, where.Eq("id", 1)) fmt.Println(movie.Title) }
Output: Golang
Index ¶
- Variables
- type Assert
- type MockAggregate
- type MockCount
- type MockDelete
- func (md *MockDelete) ConnectionClosed() *Assert
- func (md *MockDelete) Error(err error) *Assert
- func (md MockDelete) ExpectString() string
- func (md *MockDelete) For(record interface{}) *MockDelete
- func (md *MockDelete) ForContains(contains interface{}) *MockDelete
- func (md *MockDelete) ForTable(typ string) *MockDelete
- func (md *MockDelete) ForType(typ string) *MockDelete
- func (md MockDelete) String() string
- func (md *MockDelete) Success() *Assert
- type MockDeleteAll
- func (mda *MockDeleteAll) ConnectionClosed() *Assert
- func (mda *MockDeleteAll) Error(err error) *Assert
- func (mda MockDeleteAll) ExpectString() string
- func (mda *MockDeleteAll) For(record interface{}) *MockDeleteAll
- func (mda *MockDeleteAll) ForTable(typ string) *MockDeleteAll
- func (mda *MockDeleteAll) ForType(typ string) *MockDeleteAll
- func (mda MockDeleteAll) String() string
- func (mda *MockDeleteAll) Success() *Assert
- type MockDeleteAny
- func (mda *MockDeleteAny) ConnectionClosed() *Assert
- func (mda *MockDeleteAny) DeletedCount(deletedCount int) *Assert
- func (mda *MockDeleteAny) Error(err error) *Assert
- func (mda MockDeleteAny) ExpectString() string
- func (mda MockDeleteAny) String() string
- func (mda *MockDeleteAny) Success() *Assert
- func (mda *MockDeleteAny) Unsafe() *MockDeleteAny
- type MockExec
- type MockFind
- type MockFindAll
- type MockFindAndCountAll
- type MockInsertAll
- func (mia *MockInsertAll) ConnectionClosed() *Assert
- func (mia *MockInsertAll) Error(err error) *Assert
- func (mia MockInsertAll) ExpectString() string
- func (mia *MockInsertAll) For(record interface{}) *MockInsertAll
- func (mia *MockInsertAll) ForTable(typ string) *MockInsertAll
- func (mia *MockInsertAll) ForType(typ string) *MockInsertAll
- func (mia *MockInsertAll) NotUnique(key string) *Assert
- func (mia MockInsertAll) String() string
- func (mia *MockInsertAll) Success() *Assert
- type MockIterate
- func (mi MockIterate) Close() error
- func (mi *MockIterate) ConnectionClosed() *Assert
- func (mi *MockIterate) Error(err error) *Assert
- func (mi MockIterate) ExpectString() string
- func (mi *MockIterate) Next(record interface{}) error
- func (mi *MockIterate) Result(result interface{}) *Assert
- func (mi MockIterate) String() string
- type MockMutate
- func (mm *MockMutate) ConnectionClosed() *Assert
- func (mm *MockMutate) Error(err error) *Assert
- func (mm MockMutate) ExpectString() string
- func (mm *MockMutate) For(record interface{}) *MockMutate
- func (mm *MockMutate) ForContains(contains interface{}) *MockMutate
- func (mm *MockMutate) ForTable(typ string) *MockMutate
- func (mm *MockMutate) ForType(typ string) *MockMutate
- func (mm *MockMutate) NotUnique(key string) *Assert
- func (mm MockMutate) String() string
- func (mm *MockMutate) Success() *Assert
- type MockPreload
- func (mp *MockPreload) ConnectionClosed() *Assert
- func (mp *MockPreload) Error(err error) *Assert
- func (mp MockPreload) ExpectString() string
- func (md *MockPreload) For(records interface{}) *MockPreload
- func (md *MockPreload) ForType(typ string) *MockPreload
- func (mp *MockPreload) Result(result interface{}) *Assert
- func (mp MockPreload) String() string
- type MockUpdateAny
- func (mua *MockUpdateAny) ConnectionClosed() *Assert
- func (mua *MockUpdateAny) Error(err error) *Assert
- func (mua MockUpdateAny) ExpectString() string
- func (mua MockUpdateAny) String() string
- func (mua *MockUpdateAny) Unsafe() *MockUpdateAny
- func (mua *MockUpdateAny) UpdatedCount(updatedCount int) *Assert
- type Repository
- func (r *Repository) Adapter(ctx context.Context) rel.Adapter
- func (r *Repository) Aggregate(ctx context.Context, query rel.Query, aggregate string, field string) (int, error)
- func (r *Repository) AssertExpectations(t T) bool
- func (r *Repository) Count(ctx context.Context, collection string, queriers ...rel.Querier) (int, error)
- func (r *Repository) Delete(ctx context.Context, record interface{}, options ...rel.Mutator) error
- func (r *Repository) DeleteAll(ctx context.Context, records interface{}) error
- func (r *Repository) DeleteAny(ctx context.Context, query rel.Query) (int, error)
- func (r *Repository) Exec(ctx context.Context, statement string, args ...interface{}) (int, int, error)
- func (r *Repository) ExpectAggregate(query rel.Query, aggregate string, field string) *MockAggregate
- func (r *Repository) ExpectCount(collection string, queriers ...rel.Querier) *MockCount
- func (r *Repository) ExpectDelete(options ...rel.Mutator) *MockDelete
- func (r *Repository) ExpectDeleteAll() *MockDeleteAll
- func (r *Repository) ExpectDeleteAny(query rel.Query) *MockDeleteAny
- func (r *Repository) ExpectExec(statement string, args ...interface{}) *MockExec
- func (r *Repository) ExpectFind(queriers ...rel.Querier) *MockFind
- func (r *Repository) ExpectFindAll(queriers ...rel.Querier) *MockFindAll
- func (r *Repository) ExpectFindAndCountAll(queriers ...rel.Querier) *MockFindAndCountAll
- func (r *Repository) ExpectInsert(mutators ...rel.Mutator) *MockMutate
- func (r *Repository) ExpectInsertAll() *MockInsertAll
- func (r *Repository) ExpectIterate(query rel.Query, options ...rel.IteratorOption) *MockIterate
- func (r *Repository) ExpectPreload(field string, queriers ...rel.Querier) *MockPreload
- func (r *Repository) ExpectTransaction(fn func(*Repository))
- func (r *Repository) ExpectUpdate(mutators ...rel.Mutator) *MockMutate
- func (r *Repository) ExpectUpdateAny(query rel.Query, mutates ...rel.Mutate) *MockUpdateAny
- func (r *Repository) Find(ctx context.Context, record interface{}, queriers ...rel.Querier) error
- func (r *Repository) FindAll(ctx context.Context, records interface{}, queriers ...rel.Querier) error
- func (r *Repository) FindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) (int, error)
- func (r *Repository) Insert(ctx context.Context, record interface{}, mutators ...rel.Mutator) error
- func (r *Repository) InsertAll(ctx context.Context, records interface{}, mutators ...rel.Mutator) error
- func (r *Repository) Instrumentation(instrumenter rel.Instrumenter)
- func (r *Repository) Iterate(ctx context.Context, query rel.Query, options ...rel.IteratorOption) rel.Iterator
- func (r *Repository) MustAggregate(ctx context.Context, query rel.Query, aggregate string, field string) int
- func (r *Repository) MustCount(ctx context.Context, collection string, queriers ...rel.Querier) int
- func (r *Repository) MustDelete(ctx context.Context, record interface{}, options ...rel.Mutator)
- func (r *Repository) MustDeleteAll(ctx context.Context, record interface{})
- func (r *Repository) MustDeleteAny(ctx context.Context, query rel.Query) int
- func (r *Repository) MustExec(ctx context.Context, statement string, args ...interface{}) (int, int)
- func (r *Repository) MustFind(ctx context.Context, record interface{}, queriers ...rel.Querier)
- func (r *Repository) MustFindAll(ctx context.Context, records interface{}, queriers ...rel.Querier)
- func (r *Repository) MustFindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) int
- func (r *Repository) MustInsert(ctx context.Context, record interface{}, mutators ...rel.Mutator)
- func (r *Repository) MustInsertAll(ctx context.Context, records interface{}, mutators ...rel.Mutator)
- func (r *Repository) MustPreload(ctx context.Context, records interface{}, field string, ...)
- func (r *Repository) MustUpdate(ctx context.Context, record interface{}, mutators ...rel.Mutator)
- func (r *Repository) MustUpdateAny(ctx context.Context, query rel.Query, mutates ...rel.Mutate) int
- func (r *Repository) Ping(ctx context.Context) error
- func (r *Repository) Preload(ctx context.Context, records interface{}, field string, ...) error
- func (r *Repository) Transaction(ctx context.Context, fn func(ctx context.Context) error) error
- func (r *Repository) Update(ctx context.Context, record interface{}, mutators ...rel.Mutator) error
- func (r *Repository) UpdateAny(ctx context.Context, query rel.Query, mutates ...rel.Mutate) (int, error)
- type T
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Any interface{} = any{}
var ( // ErrConnectionClosed is alias for sql.ErrConnDone. ErrConnectionClosed = sql.ErrConnDone )
Functions ¶
This section is empty.
Types ¶
type Assert ¶
type Assert struct {
// contains filtered or unexported fields
}
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 ¶
ConnectionClosed sets this error to be returned.
func (MockCount) ExpectString ¶
ExpectString 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(record interface{}) *MockDelete
For assert calls for given record.
func (*MockDelete) ForContains ¶
func (md *MockDelete) ForContains(contains interface{}) *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(record interface{}) *MockDeleteAll
For assert calls for given record.
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 records without where condition.
type MockExec ¶
type MockExec struct {
// contains filtered or unexported fields
}
MockExec asserts and simulate UpdateAny function for test.
func (*MockExec) ConnectionClosed ¶
ConnectionClosed sets this error to be returned.
func (MockExec) ExpectString ¶
ExpectString 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 ¶
ConnectionClosed sets this error to be returned.
func (MockFind) ExpectString ¶
ExpectString 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 interface{}) *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 interface{}, 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(record interface{}) *MockInsertAll
For assert calls for given record.
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
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(record interface{}) error
func (*MockIterate) Result ¶
func (mi *MockIterate) Result(result interface{}) *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(record interface{}) *MockMutate
For assert calls for given record.
func (*MockMutate) ForContains ¶
func (mm *MockMutate) ForContains(contains interface{}) *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(records interface{}) *MockPreload
For assert calls for given record.
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 interface{}) *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 records 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 is an autogenerated mock type for the Repository type
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 T) 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) DeleteAll ¶
func (r *Repository) DeleteAll(ctx context.Context, records interface{}) error
DeleteAll provides DeleteAll mock function with given fields: records
func (*Repository) Exec ¶
func (r *Repository) Exec(ctx context.Context, statement string, args ...interface{}) (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 ...interface{}) *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 records.
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) FindAll ¶
func (r *Repository) FindAll(ctx context.Context, records interface{}, queriers ...rel.Querier) error
FindAll provides a mock function with given fields: records, queriers
func (*Repository) FindAndCountAll ¶
func (r *Repository) FindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) (int, error)
FindAndCountAll provides a mock function with given fields: records, queriers
func (*Repository) InsertAll ¶
func (r *Repository) InsertAll(ctx context.Context, records interface{}, mutators ...rel.Mutator) error
InsertAll records.
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 records from database in batches. This function returns iterator that can be used to loop all records. 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 ¶
MustCount provides a mock function with given fields: collection, queriers
func (*Repository) MustDelete ¶
func (r *Repository) MustDelete(ctx context.Context, record interface{}, options ...rel.Mutator)
MustDelete provides a mock function with given fields: record
func (*Repository) MustDeleteAll ¶
func (r *Repository) MustDeleteAll(ctx context.Context, record interface{})
MustDeleteAll provides a mock function with given fields: record
func (*Repository) MustDeleteAny ¶
MustDeleteAny provides a mock function with given fields: query
func (*Repository) MustExec ¶
func (r *Repository) MustExec(ctx context.Context, statement string, args ...interface{}) (int, int)
MustExec raw statement. Returns last inserted id, rows affected and error.
func (*Repository) MustFind ¶
func (r *Repository) MustFind(ctx context.Context, record interface{}, queriers ...rel.Querier)
MustFind provides a mock function with given fields: record, queriers
func (*Repository) MustFindAll ¶
func (r *Repository) MustFindAll(ctx context.Context, records interface{}, queriers ...rel.Querier)
MustFindAll provides a mock function with given fields: records, queriers
func (*Repository) MustFindAndCountAll ¶
func (r *Repository) MustFindAndCountAll(ctx context.Context, records interface{}, queriers ...rel.Querier) int
MustFindAndCountAll provides a mock function with given fields: records, queriers
func (*Repository) MustInsert ¶
func (r *Repository) MustInsert(ctx context.Context, record interface{}, mutators ...rel.Mutator)
MustInsert provides a mock function with given fields: record, mutators
func (*Repository) MustInsertAll ¶
func (r *Repository) MustInsertAll(ctx context.Context, records interface{}, mutators ...rel.Mutator)
MustInsertAll records.
func (*Repository) MustPreload ¶
func (r *Repository) MustPreload(ctx context.Context, records interface{}, field string, queriers ...rel.Querier)
MustPreload provides a mock function with given fields: records, field, queriers
func (*Repository) MustUpdate ¶
func (r *Repository) MustUpdate(ctx context.Context, record interface{}, mutators ...rel.Mutator)
MustUpdate provides a mock function with given fields: record, mutators
func (*Repository) MustUpdateAny ¶
MustUpdateAny provides a mock function with given fields: query
func (*Repository) Preload ¶
func (r *Repository) Preload(ctx context.Context, records interface{}, field string, queriers ...rel.Querier) error
Preload provides a mock function with given fields: records, field, queriers
func (*Repository) Transaction ¶
Transaction provides a mock function with given fields: fn