mysql

package module
v0.0.0-...-01b41fc Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 6 Imported by: 0

README

MySQL GoDoc Go Report Card

This package provides a MySQL Box using Conex.

Usage

package example_test

import (
  "testing"

  "github.com/omeid/conex"
  "github.com/conex/mysql"
  _ "github.com/go-sql-driver/mysql" // Bring your own driver!
)

func TestMain(m *testing.M) {
  conex.Main(m)
}

func TestMySQL(t *testing.T) {
  db, container := mysql.Box(t, nil)
  defer container.Drop()

  // use db to interact with the database
}

Note: You must import your preferred sql driver (e.g., _ "github.com/go-sql-driver/mysql") in your tests, as the plugin does not register one automatically.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Image to use for the box.
	Image = "mysql:8"
	// Port used for connect to MySQL.
	Port = "3306"

	// MySQLUpWaitTime dictates how long we should wait for MySQL to accept connections on {{Port}}.
	MySQLUpWaitTime = 30 * time.Second
)

Functions

func Box

func Box(t testing.TB, config *Config) (*sql.DB, conex.Container)

Box returns a MySQL client and the container running the MySQL server. It will call t.Fatal on errors.

Types

type Config

type Config struct {
	User     string // leave blank for root, otherwise provide a password
	Password string // can be blank for root user
	Database string // defaults to `test`
	// contains filtered or unexported fields
}

Config used to connect to the database.

Jump to

Keyboard shortcuts

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