mysql

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mysql. helpers.go - Internal helpers for the MySQL driver: io helpers, container file copy, and the wait-strategy builder. Kept separate so the main mysql.go file stays focused on the DatabaseDriver contract.

Package mysql. mysql.go - MySQL backend for dbtestkit. Boots a MySQL 8.x test container using testcontainers-go, with a tmpfs-backed data directory and an optimized entrypoint that re-hydrates a pre-baked empty database tarball (skipping the multi-second initdb phase).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New returns a fresh MySQL driver instance.

Pass the result to dbtestkit.WithDriver:

dbtestkit.Run(m,
    dbtestkit.WithDriver(mysql.New()),
    ...
)

Types

type MySQLDriver added in v0.3.2

type MySQLDriver struct {
	// contains filtered or unexported fields
}

MySQLDriver implements dbtestkit.DatabaseDriver for MySQL.

func (*MySQLDriver) Driver added in v0.3.2

func (d *MySQLDriver) Driver() dbtestkit.Driver

Driver returns the dbtestkit.Driver constant this implementation serves.

func (*MySQLDriver) GenerateDump added in v0.3.2

func (d *MySQLDriver) GenerateDump(ctx context.Context, env *dbtestkit.Environment, dumpPath string) error

GenerateDump dumps the current database to dumpPath via mysqldump.

The dump is generated with --add-drop-table so restores are idempotent and do not require a separate TRUNCATE pass.

func (*MySQLDriver) ResetStrategy added in v0.3.2

func (d *MySQLDriver) ResetStrategy() dbtestkit.ResetStrategy

ResetStrategy returns RestoreDump to utilize the fast-path CLI pipe.

func (*MySQLDriver) RestoreDump added in v0.3.2

func (d *MySQLDriver) RestoreDump(ctx context.Context, env *dbtestkit.Environment, dumpPath string) error

RestoreDump pipes the pristine SQL dump into the MySQL CLI client inside the container. This is the fast-path reset (~ms).

func (*MySQLDriver) Start added in v0.3.2

func (d *MySQLDriver) Start(ctx context.Context, env *dbtestkit.Environment) (string, error)

Start boots the MySQL container and returns the DSN.

The container is configured with:

  • tmpfs at /var/lib/mysql for in-memory storage (fast + ephemeral)
  • an optimized entrypoint that re-hydrates a pre-baked empty DB tarball (skipping initdb's slow first-run sequence)
  • no wait strategy — the entrypoint guarantees readiness before exec returns control

func (*MySQLDriver) Stop added in v0.3.2

Stop terminates the container.

func (*MySQLDriver) Truncate added in v0.3.2

Truncate is a no-op for MySQL — the pristine dump's DROP TABLE IF EXISTS statements make truncation redundant on the fast path.

Jump to

Keyboard shortcuts

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