class

Testcontainers::MysqlContainer

Inherits Testcontainers::DockerContainer < Reference < Object

MysqlContainer provides a pre-configured container for MySQL.

Example:

container = Testcontainers::MysqlContainer.new
container.start

url = container.database_url
# => "mysql://test:test@localhost:32768/test"

container.stop
container.remove

Constants

MYSQL_DEFAULT_DATABASE = "test"
MYSQL_DEFAULT_IMAGE = "mysql:latest"
MYSQL_DEFAULT_PASSWORD = "test"
MYSQL_DEFAULT_PORT = 3306
MYSQL_DEFAULT_ROOT_PASSWORD = "test"
MYSQL_DEFAULT_USERNAME = "test"

Constructors

new(image : String = MYSQL_DEFAULT_IMAGE, root_password : String = ENV.fetch("MYSQL_ROOT_PASSWORD", MYSQL_DEFAULT_ROOT_PASSWORD), username : String = ENV.fetch("MYSQL_USER", MYSQL_DEFAULT_USERNAME), password : String = ENV.fetch("MYSQL_PASSWORD", MYSQL_DEFAULT_PASSWORD), database : String = ENV.fetch("MYSQL_DATABASE", MYSQL_DEFAULT_DATABASE))
Source

Instance methods

database
Source
database_url(protocol : String = "mysql", username : String | Nil = nil, password : String | Nil = nil, database : String | Nil = nil, options : Hash(String, String) = Hash(String, String).new) : String

Returns the database URL.

Source
password
Source
port

Returns the default port.

Source
root_password
Source
start

Starts the container.

Source
username
Source
with_database(database : String) : self

Sets the database name.

Source
with_password(password : String) : self

Sets the password.

Source
with_root_password(root_password : String) : self

Sets the root password.

Source
with_username(username : String) : self

Sets the username.

Source