test

package
v3.0.0-...-890dad5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSettings

func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings) (settings sqlds.DriverSettings, err error)

LoadSettings will read and validate Settings from the DataSourceConfig

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
	ConnectError     error
	ConnectFailTimes int
	OnConnect        func(msg []byte)
	QueryDelay       int
	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(msg json.RawMessage) (*sql.DB, error), converters []sqlutil.Converter) TestDS

NewTestDS creates a new test datasource driver

func (TestDS) Connect

Connect - connects to the test database

func (TestDS) Converters

func (s TestDS) Converters() []sqlutil.Converter

Converters - Converters for the test database

func (TestDS) Macros

func (s TestDS) Macros() sqlds.Macros

Macros - Macros for the test database

func (TestDS) Open

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

Open - opens the test database

func (TestDS) Settings

func (s TestDS) Settings(ctx context.Context, config backend.DataSourceInstanceSettings) sqlds.DriverSettings

Settings - Settings to the test database

Jump to

Keyboard shortcuts

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