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) (*proto.QueryResult, 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() []proto.Field
- func (conn *Conn) GetCharset() (cs proto.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 proto.Charset) error
- func (conn *Conn) Shutdown()
- type DB
- func (db *DB) AddQuery(query string, expectedResult *proto.QueryResult)
- 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) (*proto.QueryResult, 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) (*proto.QueryResult, 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 ¶
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 ¶
SetCharset changes the per-session character set variables.
type DB ¶
type DB struct {
// 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) AddQuery ¶
func (db *DB) AddQuery(query string, expectedResult *proto.QueryResult)
AddQuery adds a query and its expected result.
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) GetQuery ¶
func (db *DB) GetQuery(query string) (*proto.QueryResult, bool)
GetQuery gets a query from the fake DB.
func (*DB) GetQueryCalledNum ¶
GetQueryCalledNum returns how many times db executes a certain query.
func (*DB) IsConnFail ¶
IsConnFail tests whether there is a connection failure.