ksql

package
v0.7.2 Latest Latest
Warning

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

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

Documentation

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 is used to override driver.Conn interface methods to mock the outputs of the querries.

func (Conn) Begin

func (c Conn) Begin() (driver.Tx, error)

func (Conn) BeginTx

func (c Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx mocks the encoded outputs of BeginTx in test mode and captures encoded outputs in capture mode.

func (Conn) Close

func (c Conn) Close() error

func (Conn) ExecContext

func (c Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

ExecContext is the mocked method of driver.ExecerContext interface. Parameters and returned variables are same as ExecContext method of database/sql/driver package.

Note: ctx parameter should be the http's request context. If you are using gorm then, first call gorm.DB.WithContext(r.Context()) in your Handler function.

func (Conn) OpenConnector

func (c Conn) OpenConnector(name string) (driver.Connector, error)

func (Conn) Ping

func (c Conn) Ping(ctx context.Context) error

Ping is the mocked method of sql/driver's Ping.

func (Conn) Prepare

func (c Conn) Prepare(query string) (driver.Stmt, error)

func (Conn) PrepareContext

func (c Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext mocks the outputs of PrepareContext method of sql/driver's ConnPrepareContext interface.

func (Conn) QueryContext

func (c Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContext mocks the outputs of QueryContext method of sql driver's QueryerContext interface.

type Driver

type Driver struct {
	driver.Driver
}

Driver wraps the sql driver to overrides Open method of driver.Driver.

func (*Driver) Open

func (ksql *Driver) Open(dsn string) (driver.Conn, error)

Open returns wrapped driver.Conn in order to mock outputs of sql Querries.

dsn is a string in driver specific format used as connection URI.

type Result

type Result struct {
	LastInserted int64
	LError       string
	RowsAff      int64
	RError       string
}

Result is used to encode/decode driver.Result interface so that, its outputs could be stored in the keploy context.

func (Result) LastInsertId

func (r Result) LastInsertId() (int64, error)

func (Result) RowsAffected

func (r Result) RowsAffected() (int64, error)

type Rows

type Rows struct {
	driver.Rows
	// contains filtered or unexported fields
}

Rows mocks the driver.Rows methods to store their encoded outputs.

func (Rows) Close

func (r Rows) Close() error

Close mocks the output of Close method of your SQL driver.

func (Rows) Columns

func (r Rows) Columns() []string

Columns mocks the output of Columns method of your SQL driver.

func (Rows) Next

func (r Rows) Next(dest []driver.Value) error

Next mocks the outputs of Next method of sql Driver.

type Stmt

type Stmt struct {
	driver.Stmt
	// contains filtered or unexported fields
}

Stmt wraps the driver.Stmt to mock its method's outputs.

func (Stmt) Close

func (s Stmt) Close() error

func (Stmt) Exec

func (s Stmt) Exec(args []driver.Value) (driver.Result, error)

func (Stmt) NumInput

func (s Stmt) NumInput() int

func (Stmt) Query

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

type Tx

type Tx struct {
	driver.Tx
	// contains filtered or unexported fields
}

Tx wraps driver.Tx to mock its methods output.

func (Tx) Commit

func (t Tx) Commit() error

Commit mocks the outputs of Commit method present driver's Tx interface.

func (Tx) Rollback

func (t Tx) Rollback() error

Rollback mocks the outputs of Rollback method present driver's Tx interface.

type Value

type Value struct {
	Value []driver.Value
}

Value wraps the Value from the sql driver to encode/decode using gob.

func (*Value) GobDecode

func (d *Value) GobDecode(b []byte) error

GobDecode decodes Values using gob Decoder.

func (*Value) GobEncode

func (d *Value) GobEncode() ([]byte, error)

GobEncode encodes the Value using gob Encoder.

Jump to

Keyboard shortcuts

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