sqlstub

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sqlstub contains stub implementations of sql/driver interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector struct {
	driver.Connector

	ConnectFunc func(context.Context) (driver.Conn, error)
	DriverFunc  func() driver.Driver
}

Connector is a test implementation of the driver.Connector interface.

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a connection to the database.

func (*Connector) Driver

func (c *Connector) Driver() driver.Driver

Driver returns the underlying Driver of the Connector.

type Driver

type Driver struct {
	driver.Driver

	OpenFunc func(string) (driver.Conn, error)
}

Driver is a test implementation of the driver.Driver interface.

func RegisterDriver

func RegisterDriver() (string, *Driver)

RegisterDriver creates a Driver stub and registers it with the sql package.

It returns the driver name that can be used with sql.Open() and the Driver stub itself.

func (*Driver) Open

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

Open returns a new connection to the database.

Jump to

Keyboard shortcuts

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