sqltest

package
v0.0.0-...-eadad3b Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sqltest contains utilities for connecting to SQL test databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DSN

func DSN(driver string) (string, func())

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

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

func MockDB

func MockDB() *sql.DB

MockDB returns a database pool that uses the mock connector.

func MockDriverName

func MockDriverName() string

MockDriverName returns the mock driver name for use with sql.Open().

func Open

func Open(
	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

type MockConnector struct {
	driver.Connector
}

MockConnector is mock of the driver.Connector interface.

func (*MockConnector) Driver

func (*MockConnector) Driver() driver.Driver

Driver returns the connector's driver.

type MockDriver

type MockDriver struct {
	driver.Driver
}

MockDriver is mock of the driver.Driver interface.

Jump to

Keyboard shortcuts

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