drivertest

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package drivertest contains a common test suite for all SQL drivers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DSN added in v0.3.2

func DSN(prod Product, driver string) (string, func())

DSN returns the DSN for the test database to use with the given database product and SQL driver.

The returned function must be used to cleanup any data created for the DSN, such as temporary on-disk databases.

func Declare

func Declare(
	d pksql.Driver,
	setup func(context.Context) *sql.DB,
)

Declare declares generic behavioral tests for a specific driver implementation.

func MockDB added in v0.3.0

func MockDB() *sql.DB

MockDB returns a database pool that uses the mock connector.

func Open added in v0.3.2

func Open(
	prod Product,
	driver string,
) (
	db *sql.DB,
	dsn string,
	close func(),
)

Open returns the test database to use with the given driver.

The returned function must be used to close the database, instead of DB.Close().

Types

type MockConnector added in v0.3.0

type MockConnector struct {
	driver.Connector
}

MockConnector is mock of the driver.Connector interface.

func (*MockConnector) Driver added in v0.3.0

func (*MockConnector) Driver() driver.Driver

Driver returns the connector's driver.

type MockDriver added in v0.3.0

type MockDriver struct {
	driver.Driver
}

MockDriver is mock of the driver.Driver interface.

type Product added in v0.5.1

type Product string

Product is an enumeration of supported database products.

const (
	// MySQL is the product enumeration value for MariaDB.
	MySQL Product = "mysql"

	// MariaDB is the product enumeration value for MariaDB.
	MariaDB Product = "mariadb"

	// PostgreSQL is the product enumeration value for PostgreSQL.
	PostgreSQL Product = "postgresql"

	// SQLite is the product enumeration value for SQLite.
	SQLite Product = "sqlite"
)

Jump to

Keyboard shortcuts

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