mysqltest

package module
v0.0.0-...-b1edc3a Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 12 Imported by: 0

README

mysqltest

Go library to spawn single-use MySQL / MariaDB servers for unit testing

Build Status GoDoc

Spawns a MySQL / MariaDB server with a single database configured. Ideal for unit tests where you want a clean instance each time. Then clean up afterwards.

Features:

  • Starts a clean isolated MySQL / MariaDB database
  • Tested on Fedora and Ubuntu

Usage

In your unit test:

mysql, err := mysqltest.Start()
defer mysql.Stop()

// Do something with mysql.DB (which is a *sql.DB)

License

This library is distributed under the MIT license.

Documentation

Overview

Spawns a MySQL server with a single database configured. Ideal for unit tests where you want a clean instance each time. Then clean up afterwards.

Requires MySQL to be installed on your system (but it doesn't have to be running).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQL

type MySQL struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

func Start

func Start() (*MySQL, error)

Start a new MySQL database, on temporary storage.

Use the DB field to access the database connection

func (*MySQL) Stop

func (p *MySQL) Stop() error

Stop the database and remove storage files.

Jump to

Keyboard shortcuts

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