An open API service indexing awesome lists of open source software.

https://github.com/rubenv/mysqltest

MySQL / MariaDB test helper for Go
https://github.com/rubenv/mysqltest

Last synced: 17 days ago
JSON representation

MySQL / MariaDB test helper for Go

Awesome Lists containing this project

README

          

# mysqltest

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

[![Build Status](https://github.com/rubenv/mysqltest/workflows/Test/badge.svg)](https://github.com/rubenv/mysqltest/actions) [![GoDoc](https://godoc.org/github.com/rubenv/mysqltest?status.png)](https://godoc.org/github.com/rubenv/mysqltest)

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:
```go
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) license.