Documentation ¶
Index ¶
- Variables
- func Dump()
- func ParseTime(layout string)
- func Reset()
- func Verbose(v bool)
- type ExecStub
- func (s *ExecStub) Args(args ...driver.Value) *ExecStub
- func (s *ExecStub) Dump() *ExecStub
- func (s *ExecStub) From(table string) *ExecStub
- func (s *ExecStub) Into(table string) *ExecStub
- func (s *ExecStub) Notify(ch chan<- struct{}) *ExecStub
- func (s *ExecStub) Priority(p int) *ExecStub
- func (s *ExecStub) Stub(res driver.Result)
- func (s *ExecStub) StubError(err error)
- func (s *ExecStub) StubResult(lastInsertID, rowsAffected int64)
- func (s *ExecStub) StubRowsAffected(rowsAffected int64)
- func (s *ExecStub) Table(table string) *ExecStub
- func (s *ExecStub) Value(col string, v interface{}) *ExecStub
- func (s *ExecStub) ValueAt(row int, col string, v interface{}) *ExecStub
- func (s *ExecStub) Where(col string, v ...interface{}) *ExecStub
- func (s *ExecStub) WhereOp(col string, operator string, v ...interface{}) *ExecStub
- type Stub
- func (s *Stub) Args(args ...driver.Value) *Stub
- func (s *Stub) Dump() *Stub
- func (s *Stub) From(tables ...string) *Stub
- func (s *Stub) Notify(ch chan<- struct{}) *Stub
- func (s *Stub) Priority(p int) *Stub
- func (s *Stub) Stub(rows [][]driver.Value)
- func (s *Stub) StubCSV(data string)
- func (s *Stub) StubError(err error)
- func (s *Stub) Subquery() subquery
- func (s *Stub) Where(col string, v ...interface{}) *Stub
- func (s *Stub) WhereOp(col string, operator string, v ...interface{}) *Stub
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnstubbed is returned as the result for unstubbed queries. ErrUnstubbed = errors.New("mogi: query not stubbed") // ErrUnresolved is returned as the result of a stub that was matched, // but whose data could not be resolved. For example, exceeded LIMITs. ErrUnresolved = errors.New("mogi: query matched but no stub data") )
Functions ¶
func Dump ¶
func Dump()
Dump prints all the current stubs, in order of priority. Helpful for debugging.
Types ¶
type ExecStub ¶
type ExecStub struct {
// contains filtered or unexported fields
}
ExecStub is a SQL exec stub (for INSERT, UPDATE, DELETE)
func Insert ¶
Insert starts a new stub for INSERT statements. You can filter out which columns to use this stub for. If you don't pass any columns, it will stub all INSERT queries.
func Update ¶
Update starts a new stub for UPDATE statements. You can filter out which columns (from the SET statement) this stub is for. If you don't pass any columns, it will stub all UPDATE queries.
func (*ExecStub) Args ¶
Args further filters this stub, matching based on the args passed to the query
func (*ExecStub) Notify ¶
Notify will have this stub send to the given channel when matched. You should put this as the last part of your stub chain.
func (*ExecStub) Priority ¶
Priority adds the given priority to this stub, without performing any matching.
func (*ExecStub) StubResult ¶
StubResult is an easy way to stub a driver.Result. Given a value of -1, the result will return an error for that particular part.
func (*ExecStub) StubRowsAffected ¶
StubRowsAffected is an easy way to stub a driver.Result when you only need to specify the rows affected.
func (*ExecStub) Table ¶
Table further filters this stub, matching the target table in INSERT, UPDATE, or DELETE.
func (*ExecStub) Value ¶
Value further filters this stub, matching based on values supplied to the query For INSERTs, it matches the first row of values, so it is a shortcut for ValueAt(0, ...) For UPDATEs, it matches on the SET clause.
func (*ExecStub) ValueAt ¶
ValueAt further filters this stub, matching based on values supplied to the query
type Stub ¶
type Stub struct {
// contains filtered or unexported fields
}
Stub is a SQL query stub (for SELECT)
func Select ¶
Select starts a new stub for SELECT statements. You can filter out which columns to use this stub for. If you don't pass any columns, it will stub all SELECT queries.
func (*Stub) From ¶
From further filters this stub by table names in the FROM and JOIN clauses (in order). You need to give it the un-aliased table names.
func (*Stub) Notify ¶
Notify will have this stub send to the given channel when matched. You should put this as the last part of your stub chain.
func (*Stub) Priority ¶
Priority adds the given priority to this stub, without performing any matching.