testcontainers-cpp 0.2.0
Native C++20 Testcontainers over the Docker Engine API
Loading...
Searching...
No Matches
testcontainers::modules::MariaDBContainer Class Reference

A running MariaDB server: connection getters plus the owned container. More...

#include <testcontainers/modules/MariaDB.hpp>

Public Member Functions

const std::string & host () const noexcept
 The address a client in the test process connects to.
std::uint16_t port () const noexcept
 The host port published for the server port 3306.
const std::string & username () const noexcept
const std::string & password () const noexcept
const std::string & root_password () const noexcept
 Root's password — always equal to password() by construction (empty only for a passwordless-root config).
const std::string & database () const noexcept
std::string connection_string () const
 The server URL, mysql://user[:password]@host:port[/database] — MariaDB speaks the MySQL wire protocol, and the mysql scheme is what URL-parsing clients accept ("mariadb://" is widely rejected).
Containercontainer () noexcept
 The underlying container.
const Containercontainer () const noexcept

Friends

class MariaDBImage

Detailed Description

A running MariaDB server: connection getters plus the owned container.

Move-only — it owns the core Container, whose destructor force-removes the server (RAII teardown; container().keep() or reuse opt out, see Container).

Member Function Documentation

◆ host()

const std::string & testcontainers::modules::MariaDBContainer::host ( ) const
inlinenoexcept

The address a client in the test process connects to.

Resolved once, when the container started.

◆ port()

std::uint16_t testcontainers::modules::MariaDBContainer::port ( ) const
inlinenoexcept

The host port published for the server port 3306.

Resolved once, when the container started; a container restarted by hand gets fresh ephemeral ports — re-resolve via container() then.

◆ username()

const std::string & testcontainers::modules::MariaDBContainer::username ( ) const
inlinenoexcept

◆ password()

const std::string & testcontainers::modules::MariaDBContainer::password ( ) const
inlinenoexcept

◆ root_password()

const std::string & testcontainers::modules::MariaDBContainer::root_password ( ) const
inlinenoexcept

Root's password — always equal to password() by construction (empty only for a passwordless-root config).

◆ database()

const std::string & testcontainers::modules::MariaDBContainer::database ( ) const
inlinenoexcept

◆ connection_string()

std::string testcontainers::modules::MariaDBContainer::connection_string ( ) const

The server URL, mysql://user[:password]@host:port[/database] — MariaDB speaks the MySQL wire protocol, and the mysql scheme is what URL-parsing clients accept ("mariadb://" is widely rejected).

No path segment when the database name is empty; components percent-encoded.

◆ container() [1/2]

Container & testcontainers::modules::MariaDBContainer::container ( )
inlinenoexcept

The underlying container.

The in-container client binaries carry the mariadb-prefixed names (mariadb, mariadb-admin, mariadb-dump) — the historical mysql-prefixed names are deprecated in this image. E.g. container().exec({"mariadb", "-h127.0.0.1", "-utest", "-ptest", "-Dtest", "-e", "SELECT 1"}).

◆ container() [2/2]

const Container & testcontainers::modules::MariaDBContainer::container ( ) const
inlinenoexcept

◆ MariaDBImage

friend class MariaDBImage
friend