Documentation ¶
Overview ¶
Package fakesqldb provides a fake implementation of sqldb.Conn
Index ¶
- type Conn
- func (conn *Conn) Close()
- func (conn *Conn) CloseResult()
- func (conn *Conn) ExecuteFetch(query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (conn *Conn) ExecuteFetchMap(query string) (map[string]string, error)
- func (conn *Conn) ExecuteStreamFetch(query string) error
- func (conn *Conn) FetchNext() ([]sqltypes.Value, error)
- func (conn *Conn) Fields() ([]*querypb.Field, error)
- func (conn *Conn) GetCharset() (cs *binlogdatapb.Charset, err error)
- func (conn *Conn) ID() int64
- func (conn *Conn) IsClosed() bool
- func (conn *Conn) ReadPacket() ([]byte, error)
- func (conn *Conn) SendCommand(command uint32, data []byte) error
- func (conn *Conn) SetCharset(cs *binlogdatapb.Charset) error
- func (conn *Conn) Shutdown()
- type DB
- func (db *DB) AddQuery(query string, expectedResult *sqltypes.Result)
- func (db *DB) AddRejectedQuery(query string, err error)
- func (db *DB) DeleteQuery(query string)
- func (db *DB) DeleteRejectedQuery(query string)
- func (db *DB) DisableConnFail()
- func (db *DB) EnableConnFail()
- func (db *DB) GetQuery(query string) (*sqltypes.Result, bool)
- func (db *DB) GetQueryCalledNum(query string) int
- func (db *DB) IsConnFail() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn provides a fake implementation of sqldb.Conn.
func NewFakeSQLDBConn ¶
NewFakeSQLDBConn creates a new FakeSqlDBConn instance
func (*Conn) ExecuteFetch ¶
func (conn *Conn) ExecuteFetch(query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
ExecuteFetch executes the query on the connection
func (*Conn) ExecuteFetchMap ¶
ExecuteFetchMap returns a map from column names to cell data for a query that should return exactly 1 row.
func (*Conn) ExecuteStreamFetch ¶
ExecuteStreamFetch starts a streaming query to db server. Use FetchNext on the Connection until it returns nil or error
func (*Conn) GetCharset ¶
func (conn *Conn) GetCharset() (cs *binlogdatapb.Charset, err error)
GetCharset returns the current numerical values of the per-session character set variables.
func (*Conn) ReadPacket ¶
ReadPacket reads a raw packet from the connection.
func (*Conn) SendCommand ¶
SendCommand sends a raw command to the db server.
func (*Conn) SetCharset ¶
func (conn *Conn) SetCharset(cs *binlogdatapb.Charset) error
SetCharset changes the per-session character set variables.
type DB ¶
type DB struct { Name string // contains filtered or unexported fields }
DB is a fake database and all its methods are thread safe.
func Register ¶
func Register() *DB
Register registers a fake implementation of sqldb.Conn and returns its registered name
func (*DB) AddRejectedQuery ¶
AddRejectedQuery adds a query which will be rejected at execution time.
func (*DB) DeleteQuery ¶
DeleteQuery deletes query from the fake DB.
func (*DB) DeleteRejectedQuery ¶
DeleteRejectedQuery deletes query from the fake DB.
func (*DB) DisableConnFail ¶
func (db *DB) DisableConnFail()
DisableConnFail makes connection to this fake DB success.
func (*DB) EnableConnFail ¶
func (db *DB) EnableConnFail()
EnableConnFail makes connection to this fake DB fail.
func (*DB) GetQueryCalledNum ¶
GetQueryCalledNum returns how many times db executes a certain query.
func (*DB) IsConnFail ¶
IsConnFail tests whether there is a connection failure.