package testdb
import "github.com/google/trillian/storage/testdb"
Package testdb creates new databases for tests.
Created databases may use either sqlite (default) or mysql as the database driver. The default driver can be overridden via the TRILLIAN_SQL_DRIVER environment variable.
Index ¶
- func New(ctx context.Context) (*sql.DB, error)
- func NewTrillianDB(ctx context.Context) (*sql.DB, error)
- type Provider
Functions ¶
func New ¶
New creates a new, empty database with a randomly generated name. New is equivalent to Default().New(ctx).
func NewTrillianDB ¶
NewTrillianDB creates an empty database with the Trillian schema. The database name is randomly generated. NewTrillianDB is equivalent to Default().NewTrillianDB(ctx).
Types ¶
type Provider ¶
type Provider struct { // Driver is the SQL driver name used for sql.Open (e.g.: "mysql" or "sqlite3"). Driver string // DataSourceName is the data source name used for sql.Open (e.g., the database URL). DataSourceName string // CreateDataSource controls whether a new, random data source is created. // If set the true, New() firstly connects to DataSourceName, creates a randomly-generated // database (via "CREATE DATABASE") and then connects to the new database. // Useful to create random databases via a "main" data source name. CreateDataSource bool }
Provider is an object capable of creating new test databases.
func Default ¶
func Default() *Provider
Default returns the default database provider.
func MySQL ¶
func MySQL() *Provider
MySQL returns a MySQL database provider. The database must be running locally and have a root user without password.
func SQLite ¶
func SQLite() *Provider
SQLite returns a SQLite database provider.
func (*Provider) IsMySQL ¶
IsMySQL returns true if Provider uses the mysql driver.
func (*Provider) New ¶
New creates a new, empty database.
func (*Provider) NewTrillianDB ¶
NewTrillianDB creates an empty database with the Trillian schema.
Source Files ¶
- Version
- v1.0.7
- Published
- Mar 1, 2018
- Platform
- js/wasm
- Imports
- 12 packages
- Last checked
- 4 hours ago –
Tools for package owners.