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) ExecuteStreamFetch(query string) error
- func (conn *Conn) FetchNext() ([]sqltypes.Value, error)
- func (conn *Conn) Fields() ([]*querypb.Field, 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) Shutdown()
- type DB
- func (db *DB) AddQuery(query string, expectedResult *sqltypes.Result)
- func (db *DB) AddQueryPattern(queryPattern 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) ExecuteStreamFetch ¶
ExecuteStreamFetch starts a streaming query to db server. Use FetchNext on the Connection until it returns nil or error
func (*Conn) ReadPacket ¶
ReadPacket reads a raw packet from the connection.
func (*Conn) SendCommand ¶
SendCommand sends a raw command to the db server.
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) AddQueryPattern ¶
AddQueryPattern adds an expected result for a set of queries. These patterns are checked if no exact matches from AddQuery() are found. This function forces the addition of begin/end anchors (^$) and turns on case-insensitive matching mode.
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.