fakesqldb

package
v2.0.0-alpha2+incompat... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package fakesqldb provides a fake implementation of sqldb.Conn

Index

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

func NewFakeSqlDBConn(db *DB) *Conn

NewFakeSqlDBConn creates a new FakeSqlDBConn instance

func (*Conn) Close

func (conn *Conn) Close()

Close closes the db connection

func (*Conn) CloseResult

func (conn *Conn) CloseResult()

CloseResult finishes the result set

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

func (conn *Conn) ExecuteFetchMap(query string) (map[string]string, error)

ExecuteFetchMap returns a map from column names to cell data for a query that should return exactly 1 row.

func (*Conn) ExecuteStreamFetch

func (conn *Conn) ExecuteStreamFetch(query string) error

ExecuteStreamFetch starts a streaming query to db server. Use FetchNext on the Connection until it returns nil or error

func (*Conn) FetchNext

func (conn *Conn) FetchNext() ([]sqltypes.Value, error)

FetchNext returns the next row for a query

func (*Conn) Fields

func (conn *Conn) Fields() []proto.Field

Fields returns the current fields description for the query

func (*Conn) GetCharset

func (conn *Conn) GetCharset() (cs proto.Charset, err error)

GetCharset returns the current numerical values of the per-session character set variables.

func (*Conn) ID

func (conn *Conn) ID() int64

ID returns the connection id.

func (*Conn) IsClosed

func (conn *Conn) IsClosed() bool

IsClosed returns if the connection was ever closed

func (*Conn) ReadPacket

func (conn *Conn) ReadPacket() ([]byte, error)

ReadPacket reads a raw packet from the connection.

func (*Conn) SendCommand

func (conn *Conn) SendCommand(command uint32, data []byte) error

SendCommand sends a raw command to the db server.

func (*Conn) SetCharset

func (conn *Conn) SetCharset(cs proto.Charset) error

SetCharset changes the per-session character set variables.

func (*Conn) Shutdown

func (conn *Conn) Shutdown()

Shutdown invokes the low-level shutdown call on the socket associated with a connection to stop ongoing communication.

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

func (db *DB) AddRejectedQuery(query string, err error)

AddRejectedQuery adds a query which will be rejected at execution time.

func (*DB) DeleteQuery

func (db *DB) DeleteQuery(query string)

DeleteQuery deletes query from the fake DB.

func (*DB) DeleteRejectedQuery

func (db *DB) DeleteRejectedQuery(query string)

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

func (db *DB) GetQueryCalledNum(query string) int

GetQueryCalledNum returns how many times db executes a certain query.

func (*DB) IsConnFail

func (db *DB) IsConnFail() bool

IsConnFail tests whether there is a connection failure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL