test

package
v2.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDriver

func NewDriver(name string, dbdata Data, converters []sqlutil.Converter, opts DriverOpts) (TestDS, *SqlHandler)

NewDriver creates and registers a new test datasource driver

Types

type Column

type Column struct {
	Name     string
	Kind     any
	DataType string
}

Column - the column meta

type Data

type Data struct {
	Cols []Column
	Rows [][]any
}

Data - the columns/rows

type DriverOpts

type DriverOpts struct {
	ConnectDelay   int
	QueryDelay     int
	ConnectError   error
	QueryError     error
	QueryFailTimes int
}

DriverOpts the optional settings

type SqlHandler

type SqlHandler struct {
	mock.DBHandler
	Data  Data
	Opts  DriverOpts
	State State
	// contains filtered or unexported fields
}

SqlHandler handles driver functions

func NewDriverHandler

func NewDriverHandler(data Data, opts DriverOpts) SqlHandler

NewDriverHandler creates a new driver handler

func (SqlHandler) Close

func (s SqlHandler) Close() error

Close implements the database Close interface

func (SqlHandler) ColumnTypeDatabaseTypeName

func (s SqlHandler) ColumnTypeDatabaseTypeName(index int) string

ColumnTypeDatabaseTypeName returns the database type for the column

func (SqlHandler) ColumnTypeScanType

func (s SqlHandler) ColumnTypeScanType(index int) reflect.Type

ColumnTypeScanType returns the scan type for the column

func (*SqlHandler) Columns

func (s *SqlHandler) Columns() []string

Columns represents columns from a query

func (*SqlHandler) Next

func (s *SqlHandler) Next(dest []driver.Value) error

Next iterates over rows

func (*SqlHandler) Ping

func (s *SqlHandler) Ping(ctx context.Context) error

Ping represents a database ping

func (*SqlHandler) Query

func (s *SqlHandler) Query(args []driver.Value) (driver.Rows, error)

Query represents a database query

type State

type State struct {
	QueryAttempts   int
	ConnectAttempts int
}

State is the state of the connections/queries

type TestDS

type TestDS struct {
	sqlds.Driver
	// contains filtered or unexported fields
}

TestDS ...

func NewTestDS

func NewTestDS(openDBfn func() (*sql.DB, error), converters []sqlutil.Converter) TestDS

NewTestDS creates a new test datasource driver

func (TestDS) Open

func (s TestDS) Open() (*sql.DB, error)

Open - opens the test database

Jump to

Keyboard shortcuts

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