Documentation ¶
Overview ¶
Package mysql provides a Gnomock Preset for MySQL database.
This preset uses different docker images for amd64 and arm64 architectures. Even though the versions should be compatible, you should make sure that the tag being used exists in the following repositories:
amd64: https://hub.docker.com/_/mysql/ arm64: https://hub.docker.com/r/mysql/mysql-server
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Preset ¶
Preset creates a new Gmomock MySQL preset. This preset includes a MySQL specific healthcheck function, default MySQL image and port, and allows to optionally set up initial state.
When used without any configuration, it creates a superuser `gnomock` with password `gnomick`, and `mydb` database. Default MySQL version is 8.0.22.
Types ¶
type Option ¶
type Option func(*P)
Option is an optional configuration of this Gnomock preset. Use available Options to configure the container.
func WithDatabase ¶
WithDatabase creates a database with the provided name in the container. If not provided, "mydb" is used by default. WithQueries, if provided, runs against the new database.
func WithQueries ¶
WithQueries executes the provided queries against the database created with WithDatabase, or against default "mydb" database.
func WithQueriesFile ¶
WithQueriesFile sets a file name to read initial queries from. Queries from this file are executed before any other queries provided in WithQueries.
func WithUser ¶
WithUser creates a new superuser with the provided credentials in the container. If not used, the default credentials are gnomock:gnomick.
func WithVersion ¶ added in v0.9.0
WithVersion sets image version.
type P ¶
type P struct { DB string `json:"db"` User string `json:"user"` Password string `json:"password"` Queries []string `json:"queries"` QueriesFiles []string `json:"queries_files"` Version string `json:"version"` }
P is a Gnomock Preset implementation of MySQL database.
func (*P) Ports ¶
func (p *P) Ports() gnomock.NamedPorts
Ports returns ports that should be used to access this container.