fakedb

package
Version: v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Result1 result.
	Result1 = &sqltypes.Result{
		Fields: []*querypb.Field{
			{
				Name: "id",
				Type: querypb.Type_INT32,
			},
			{
				Name: "name",
				Type: querypb.Type_VARCHAR,
			},
		},
		Rows: [][]sqltypes.Value{
			{
				sqltypes.MakeTrusted(querypb.Type_INT32, []byte("11")),
				sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("1nice name")),
			},
			{
				sqltypes.MakeTrusted(querypb.Type_INT32, []byte("12")),
				sqltypes.NULL,
			},
		},
	}

	// Result2 result.
	Result2 = &sqltypes.Result{
		Fields: []*querypb.Field{
			{
				Name: "id",
				Type: querypb.Type_INT32,
			},
			{
				Name: "name",
				Type: querypb.Type_VARCHAR,
			},
		},
		Rows: [][]sqltypes.Value{
			{
				sqltypes.MakeTrusted(querypb.Type_INT32, []byte("21")),
				sqltypes.MakeTrusted(querypb.Type_VARCHAR, []byte("2nice name")),
			},
			{
				sqltypes.MakeTrusted(querypb.Type_INT32, []byte("22")),
				sqltypes.NULL,
			},
		},
	}

	// Result3 result.
	Result3 = &sqltypes.Result{}
)

Functions

func GetTmpDir

func GetTmpDir(dir, module string, log *xlog.Log) string

GetTmpDir used to create a test tmp dir dir: path specified, can be an empty string module: the name of test module

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a fake database.

func New

func New(log *xlog.Log, n int) *DB

New creates a new DB.

func (*DB) AddQuery

func (db *DB) AddQuery(query string, result *sqltypes.Result)

AddQuery used to add a query and the return result expected.

func (*DB) AddQueryDelay

func (db *DB) AddQueryDelay(query string, result *sqltypes.Result, delayMS int)

AddQueryDelay used to add query and return by delay.

func (*DB) AddQueryError

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

AddQueryError use to add a query and return the error expected.

func (*DB) AddQueryErrorPattern

func (db *DB) AddQueryErrorPattern(qp string, err error)

AddQueryErrorPattern use to add a query and return the error expected.

func (*DB) AddQueryPanic

func (db *DB) AddQueryPanic(query string)

AddQueryPanic used to add the query with panic.

func (*DB) AddQueryPattern

func (db *DB) AddQueryPattern(qp string, result *sqltypes.Result)

AddQueryPattern used to add an expected result for a set of queries.

func (*DB) AddQueryStream

func (db *DB) AddQueryStream(query string, result *sqltypes.Result)

AddQueryStream used to add a query and the streamly return result expected.

func (*DB) AddQuerys

func (db *DB) AddQuerys(query string, result ...*sqltypes.Result)

AddQuerys used to add a query and the return results expected.

func (*DB) Addrs

func (db *DB) Addrs() []string

Addrs used to get all address of the server.

func (*DB) BackendConfs

func (db *DB) BackendConfs() []*config.BackendConfig

BackendConfs used to get all backend configs.

func (*DB) Close

func (db *DB) Close()

Close used to close all the listeners.

func (*DB) GetQueryCalledNum

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

GetQueryCalledNum returns how many times db executes a certain query.

func (*DB) ResetAll

func (db *DB) ResetAll()

ResetAll will reset all, including: query and query patterns.

func (*DB) ResetErrors

func (db *DB) ResetErrors()

ResetErrors used to reset all the errors.

func (*DB) ResetPatternErrors

func (db *DB) ResetPatternErrors()

ResetPatternErrors used to reset all the error pattern.

Source Files

Jump to

Keyboard shortcuts

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