Documentation ¶
Index ¶
- func CtxWithMock(ctx context.Context, mock ...*Mock) context.Context
- func RegisterMockDB(name string)
- type Condition
- type DoNothingQueryM2Mer
- func (d *DoNothingQueryM2Mer) Add(i ...interface{}) (int64, error)
- func (d *DoNothingQueryM2Mer) AddWithCtx(ctx context.Context, i ...interface{}) (int64, error)
- func (d *DoNothingQueryM2Mer) Clear() (int64, error)
- func (d *DoNothingQueryM2Mer) ClearWithCtx(ctx context.Context) (int64, error)
- func (d *DoNothingQueryM2Mer) Count() (int64, error)
- func (d *DoNothingQueryM2Mer) CountWithCtx(ctx context.Context) (int64, error)
- func (d *DoNothingQueryM2Mer) Exist(i interface{}) bool
- func (d *DoNothingQueryM2Mer) ExistWithCtx(ctx context.Context, i interface{}) bool
- func (d *DoNothingQueryM2Mer) Remove(i ...interface{}) (int64, error)
- func (d *DoNothingQueryM2Mer) RemoveWithCtx(ctx context.Context, i ...interface{}) (int64, error)
- type DoNothingQuerySetter
- func (d *DoNothingQuerySetter) Aggregate(s string) orm.QuerySeter
- func (d *DoNothingQuerySetter) All(container interface{}, cols ...string) (int64, error)
- func (d *DoNothingQuerySetter) AllWithCtx(ctx context.Context, container interface{}, cols ...string) (int64, error)
- func (d *DoNothingQuerySetter) Count() (int64, error)
- func (d *DoNothingQuerySetter) CountWithCtx(ctx context.Context) (int64, error)
- func (d *DoNothingQuerySetter) Delete() (int64, error)
- func (d *DoNothingQuerySetter) DeleteWithCtx(ctx context.Context) (int64, error)
- func (d *DoNothingQuerySetter) Distinct() orm.QuerySeter
- func (d *DoNothingQuerySetter) Exclude(s string, i ...interface{}) orm.QuerySeter
- func (d *DoNothingQuerySetter) Exist() bool
- func (d *DoNothingQuerySetter) ExistWithCtx(ctx context.Context) bool
- func (d *DoNothingQuerySetter) Filter(s string, i ...interface{}) orm.QuerySeter
- func (d *DoNothingQuerySetter) FilterRaw(s string, s2 string) orm.QuerySeter
- func (d *DoNothingQuerySetter) ForUpdate() orm.QuerySeter
- func (d *DoNothingQuerySetter) ForceIndex(indexes ...string) orm.QuerySeter
- func (d *DoNothingQuerySetter) GetCond() *orm.Condition
- func (d *DoNothingQuerySetter) GroupBy(exprs ...string) orm.QuerySeter
- func (d *DoNothingQuerySetter) IgnoreIndex(indexes ...string) orm.QuerySeter
- func (d *DoNothingQuerySetter) Limit(limit interface{}, args ...interface{}) orm.QuerySeter
- func (d *DoNothingQuerySetter) Offset(offset interface{}) orm.QuerySeter
- func (d *DoNothingQuerySetter) One(container interface{}, cols ...string) error
- func (d *DoNothingQuerySetter) OneWithCtx(ctx context.Context, container interface{}, cols ...string) error
- func (d *DoNothingQuerySetter) OrderBy(exprs ...string) orm.QuerySeter
- func (d *DoNothingQuerySetter) OrderClauses(orders ...*order_clause.Order) orm.QuerySeter
- func (d *DoNothingQuerySetter) PrepareInsert() (orm.Inserter, error)
- func (d *DoNothingQuerySetter) PrepareInsertWithCtx(ctx context.Context) (orm.Inserter, error)
- func (d *DoNothingQuerySetter) RelatedSel(params ...interface{}) orm.QuerySeter
- func (d *DoNothingQuerySetter) RowsToMap(result *orm.Params, keyCol, valueCol string) (int64, error)
- func (d *DoNothingQuerySetter) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error)
- func (d *DoNothingQuerySetter) SetCond(condition *orm.Condition) orm.QuerySeter
- func (d *DoNothingQuerySetter) Update(values orm.Params) (int64, error)
- func (d *DoNothingQuerySetter) UpdateWithCtx(ctx context.Context, values orm.Params) (int64, error)
- func (d *DoNothingQuerySetter) UseIndex(indexes ...string) orm.QuerySeter
- func (d *DoNothingQuerySetter) Values(results *[]orm.Params, exprs ...string) (int64, error)
- func (d *DoNothingQuerySetter) ValuesFlat(result *orm.ParamsList, expr string) (int64, error)
- func (d *DoNothingQuerySetter) ValuesFlatWithCtx(ctx context.Context, result *orm.ParamsList, expr string) (int64, error)
- func (d *DoNothingQuerySetter) ValuesList(results *[]orm.ParamsList, exprs ...string) (int64, error)
- func (d *DoNothingQuerySetter) ValuesListWithCtx(ctx context.Context, results *[]orm.ParamsList, exprs ...string) (int64, error)
- func (d *DoNothingQuerySetter) ValuesWithCtx(ctx context.Context, results *[]orm.Params, exprs ...string) (int64, error)
- type DoNothingRawSetter
- func (d *DoNothingRawSetter) Exec() (sql.Result, error)
- func (d *DoNothingRawSetter) Prepare() (orm.RawPreparer, error)
- func (d *DoNothingRawSetter) QueryRow(containers ...interface{}) error
- func (d *DoNothingRawSetter) QueryRows(containers ...interface{}) (int64, error)
- func (d *DoNothingRawSetter) RowsToMap(result *orm.Params, keyCol, valueCol string) (int64, error)
- func (d *DoNothingRawSetter) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error)
- func (d *DoNothingRawSetter) SetArgs(i ...interface{}) orm.RawSeter
- func (d *DoNothingRawSetter) Values(container *[]orm.Params, cols ...string) (int64, error)
- func (d *DoNothingRawSetter) ValuesFlat(container *orm.ParamsList, cols ...string) (int64, error)
- func (d *DoNothingRawSetter) ValuesList(container *[]orm.ParamsList, cols ...string) (int64, error)
- type Mock
- func MockCommit(err error) *Mock
- func MockDBStats(stats *sql.DBStats) *Mock
- func MockDeleteWithCtx(tableName string, affectedRow int64, err error) *Mock
- func MockInsertMultiWithCtx(tableName string, cnt int64, err error) *Mock
- func MockInsertOrUpdateWithCtx(tableName string, id int64, err error) *Mock
- func MockInsertWithCtx(tableName string, id int64, err error) *Mock
- func MockLoadRelatedWithCtx(tableName string, name string, rows int64, err error) *Mock
- func MockMethod(method string, resp ...interface{}) *Mock
- func MockQueryM2MWithCtx(tableName string, name string, res orm.QueryM2Mer) *Mock
- func MockQueryTableWithCtx(tableName string, qs orm.QuerySeter) *Mock
- func MockRawWithCtx(rs orm.RawSeter) *Mock
- func MockRead(tableName string, cb func(data interface{}), err error) *Mock
- func MockReadForUpdateWithCtx(tableName string, cb func(data interface{}), err error) *Mock
- func MockReadOrCreateWithCtx(tableName string, cb func(data interface{}), insert bool, id int64, err error) *Mock
- func MockRollback(err error) *Mock
- func MockRollbackUnlessCommit(err error) *Mock
- func MockTable(tableName string, resp ...interface{}) *Mock
- func MockUpdateWithCtx(tableName string, affectedRow int64, err error) *Mock
- func NewMock(cond Condition, resp []interface{}, cb func(inv *orm.Invocation)) *Mock
- type OrmStub
- type QueryM2MerCondition
- type SimpleCondition
- type Stub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMockDB ¶
func RegisterMockDB(name string)
RegisterMockDB create an "virtual DB" by using sqllite you should not
Types ¶
type Condition ¶
type Condition interface {
Match(ctx context.Context, inv *orm.Invocation) bool
}
func NewSimpleCondition ¶
type DoNothingQueryM2Mer ¶
type DoNothingQueryM2Mer struct{}
DoNothingQueryM2Mer do nothing use it to build mock orm.QueryM2Mer
func (*DoNothingQueryM2Mer) Add ¶
func (d *DoNothingQueryM2Mer) Add(i ...interface{}) (int64, error)
func (*DoNothingQueryM2Mer) AddWithCtx ¶
func (d *DoNothingQueryM2Mer) AddWithCtx(ctx context.Context, i ...interface{}) (int64, error)
func (*DoNothingQueryM2Mer) Clear ¶
func (d *DoNothingQueryM2Mer) Clear() (int64, error)
func (*DoNothingQueryM2Mer) ClearWithCtx ¶
func (d *DoNothingQueryM2Mer) ClearWithCtx(ctx context.Context) (int64, error)
func (*DoNothingQueryM2Mer) Count ¶
func (d *DoNothingQueryM2Mer) Count() (int64, error)
func (*DoNothingQueryM2Mer) CountWithCtx ¶
func (d *DoNothingQueryM2Mer) CountWithCtx(ctx context.Context) (int64, error)
func (*DoNothingQueryM2Mer) Exist ¶
func (d *DoNothingQueryM2Mer) Exist(i interface{}) bool
func (*DoNothingQueryM2Mer) ExistWithCtx ¶
func (d *DoNothingQueryM2Mer) ExistWithCtx(ctx context.Context, i interface{}) bool
func (*DoNothingQueryM2Mer) Remove ¶
func (d *DoNothingQueryM2Mer) Remove(i ...interface{}) (int64, error)
func (*DoNothingQueryM2Mer) RemoveWithCtx ¶
func (d *DoNothingQueryM2Mer) RemoveWithCtx(ctx context.Context, i ...interface{}) (int64, error)
type DoNothingQuerySetter ¶
type DoNothingQuerySetter struct{}
DoNothingQuerySetter do nothing usually you use this to build your mock QuerySetter
func (*DoNothingQuerySetter) Aggregate ¶
func (d *DoNothingQuerySetter) Aggregate(s string) orm.QuerySeter
func (*DoNothingQuerySetter) All ¶
func (d *DoNothingQuerySetter) All(container interface{}, cols ...string) (int64, error)
func (*DoNothingQuerySetter) AllWithCtx ¶
func (*DoNothingQuerySetter) Count ¶
func (d *DoNothingQuerySetter) Count() (int64, error)
func (*DoNothingQuerySetter) CountWithCtx ¶
func (d *DoNothingQuerySetter) CountWithCtx(ctx context.Context) (int64, error)
func (*DoNothingQuerySetter) Delete ¶
func (d *DoNothingQuerySetter) Delete() (int64, error)
func (*DoNothingQuerySetter) DeleteWithCtx ¶
func (d *DoNothingQuerySetter) DeleteWithCtx(ctx context.Context) (int64, error)
func (*DoNothingQuerySetter) Distinct ¶
func (d *DoNothingQuerySetter) Distinct() orm.QuerySeter
func (*DoNothingQuerySetter) Exclude ¶
func (d *DoNothingQuerySetter) Exclude(s string, i ...interface{}) orm.QuerySeter
func (*DoNothingQuerySetter) Exist ¶
func (d *DoNothingQuerySetter) Exist() bool
func (*DoNothingQuerySetter) ExistWithCtx ¶
func (d *DoNothingQuerySetter) ExistWithCtx(ctx context.Context) bool
func (*DoNothingQuerySetter) Filter ¶
func (d *DoNothingQuerySetter) Filter(s string, i ...interface{}) orm.QuerySeter
func (*DoNothingQuerySetter) FilterRaw ¶
func (d *DoNothingQuerySetter) FilterRaw(s string, s2 string) orm.QuerySeter
func (*DoNothingQuerySetter) ForUpdate ¶
func (d *DoNothingQuerySetter) ForUpdate() orm.QuerySeter
func (*DoNothingQuerySetter) ForceIndex ¶
func (d *DoNothingQuerySetter) ForceIndex(indexes ...string) orm.QuerySeter
func (*DoNothingQuerySetter) GetCond ¶
func (d *DoNothingQuerySetter) GetCond() *orm.Condition
func (*DoNothingQuerySetter) GroupBy ¶
func (d *DoNothingQuerySetter) GroupBy(exprs ...string) orm.QuerySeter
func (*DoNothingQuerySetter) IgnoreIndex ¶
func (d *DoNothingQuerySetter) IgnoreIndex(indexes ...string) orm.QuerySeter
func (*DoNothingQuerySetter) Limit ¶
func (d *DoNothingQuerySetter) Limit(limit interface{}, args ...interface{}) orm.QuerySeter
func (*DoNothingQuerySetter) Offset ¶
func (d *DoNothingQuerySetter) Offset(offset interface{}) orm.QuerySeter
func (*DoNothingQuerySetter) One ¶
func (d *DoNothingQuerySetter) One(container interface{}, cols ...string) error
func (*DoNothingQuerySetter) OneWithCtx ¶
func (d *DoNothingQuerySetter) OneWithCtx(ctx context.Context, container interface{}, cols ...string) error
func (*DoNothingQuerySetter) OrderBy ¶
func (d *DoNothingQuerySetter) OrderBy(exprs ...string) orm.QuerySeter
func (*DoNothingQuerySetter) OrderClauses ¶
func (d *DoNothingQuerySetter) OrderClauses(orders ...*order_clause.Order) orm.QuerySeter
func (*DoNothingQuerySetter) PrepareInsert ¶
func (d *DoNothingQuerySetter) PrepareInsert() (orm.Inserter, error)
func (*DoNothingQuerySetter) PrepareInsertWithCtx ¶
func (*DoNothingQuerySetter) RelatedSel ¶
func (d *DoNothingQuerySetter) RelatedSel(params ...interface{}) orm.QuerySeter
func (*DoNothingQuerySetter) RowsToStruct ¶
func (d *DoNothingQuerySetter) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error)
func (*DoNothingQuerySetter) SetCond ¶
func (d *DoNothingQuerySetter) SetCond(condition *orm.Condition) orm.QuerySeter
func (*DoNothingQuerySetter) Update ¶
func (d *DoNothingQuerySetter) Update(values orm.Params) (int64, error)
func (*DoNothingQuerySetter) UpdateWithCtx ¶
func (*DoNothingQuerySetter) UseIndex ¶
func (d *DoNothingQuerySetter) UseIndex(indexes ...string) orm.QuerySeter
func (*DoNothingQuerySetter) ValuesFlat ¶
func (d *DoNothingQuerySetter) ValuesFlat(result *orm.ParamsList, expr string) (int64, error)
func (*DoNothingQuerySetter) ValuesFlatWithCtx ¶
func (d *DoNothingQuerySetter) ValuesFlatWithCtx(ctx context.Context, result *orm.ParamsList, expr string) (int64, error)
func (*DoNothingQuerySetter) ValuesList ¶
func (d *DoNothingQuerySetter) ValuesList(results *[]orm.ParamsList, exprs ...string) (int64, error)
func (*DoNothingQuerySetter) ValuesListWithCtx ¶
func (d *DoNothingQuerySetter) ValuesListWithCtx(ctx context.Context, results *[]orm.ParamsList, exprs ...string) (int64, error)
func (*DoNothingQuerySetter) ValuesWithCtx ¶
type DoNothingRawSetter ¶
type DoNothingRawSetter struct{}
func (*DoNothingRawSetter) Prepare ¶
func (d *DoNothingRawSetter) Prepare() (orm.RawPreparer, error)
func (*DoNothingRawSetter) QueryRow ¶
func (d *DoNothingRawSetter) QueryRow(containers ...interface{}) error
func (*DoNothingRawSetter) QueryRows ¶
func (d *DoNothingRawSetter) QueryRows(containers ...interface{}) (int64, error)
func (*DoNothingRawSetter) RowsToStruct ¶
func (d *DoNothingRawSetter) RowsToStruct(ptrStruct interface{}, keyCol, valueCol string) (int64, error)
func (*DoNothingRawSetter) SetArgs ¶
func (d *DoNothingRawSetter) SetArgs(i ...interface{}) orm.RawSeter
func (*DoNothingRawSetter) ValuesFlat ¶
func (d *DoNothingRawSetter) ValuesFlat(container *orm.ParamsList, cols ...string) (int64, error)
func (*DoNothingRawSetter) ValuesList ¶
func (d *DoNothingRawSetter) ValuesList(container *[]orm.ParamsList, cols ...string) (int64, error)
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
func MockDeleteWithCtx ¶
MockDeleteWithCtx support Delete and DeleteWithCtx
func MockInsertMultiWithCtx ¶
MockInsertMultiWithCtx support InsertMulti and InsertMultiWithCtx
func MockInsertOrUpdateWithCtx ¶
MockInsertOrUpdateWithCtx support InsertOrUpdate and InsertOrUpdateWithCtx
func MockInsertWithCtx ¶
MockInsertWithCtx support Insert and InsertWithCtx
func MockLoadRelatedWithCtx ¶
MockLoadRelatedWithCtx support LoadRelatedWithCtx and LoadRelated
func MockMethod ¶
MockMethod only check method name
func MockQueryM2MWithCtx ¶
func MockQueryM2MWithCtx(tableName string, name string, res orm.QueryM2Mer) *Mock
MockQueryM2MWithCtx support QueryM2MWithCtx and QueryM2M Now you may be need to use golang/mock to generate QueryM2M mock instance Or use DoNothingQueryM2Mer for example:
post := Post{Id: 4} m2m := Ormer.QueryM2M(&post, "Tags")
when you write test code: MockQueryM2MWithCtx("post", "Tags", mockM2Mer) "post" is the table name of model Post structure TODO provide orm.QueryM2Mer
func MockQueryTableWithCtx ¶
func MockQueryTableWithCtx(tableName string, qs orm.QuerySeter) *Mock
MockQueryTableWithCtx support QueryTableWithCtx and QueryTable
func MockRawWithCtx ¶
MockRawWithCtx support RawWithCtx and Raw
func MockRead ¶
MockOrmRead support orm.Read and orm.ReadWithCtx cb is used to mock read data from DB
func MockReadForUpdateWithCtx ¶
MockReadForUpdateWithCtx support ReadForUpdate and ReadForUpdateWithCtx cb is used to mock read data from DB
func MockReadOrCreateWithCtx ¶
func MockReadOrCreateWithCtx(tableName string, cb func(data interface{}), insert bool, id int64, err error) *Mock
MockReadOrCreateWithCtx support ReadOrCreate and ReadOrCreateWithCtx cb is used to mock read data from DB
func MockRollbackUnlessCommit ¶
MockRollbackUnlessCommit support RollbackUnlessCommit
func MockUpdateWithCtx ¶
MockUpdateWithCtx support UpdateWithCtx and Update
type QueryM2MerCondition ¶
type QueryM2MerCondition struct {
// contains filtered or unexported fields
}
func NewQueryM2MerCondition ¶
func NewQueryM2MerCondition(tableName string, name string) *QueryM2MerCondition
func (*QueryM2MerCondition) Match ¶
func (q *QueryM2MerCondition) Match(ctx context.Context, inv *orm.Invocation) bool
type SimpleCondition ¶
type SimpleCondition struct {
// contains filtered or unexported fields
}
func (*SimpleCondition) Match ¶
func (s *SimpleCondition) Match(ctx context.Context, inv *orm.Invocation) bool