mariadb

package module
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithConfigFile

func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption

func WithDatabase

func WithDatabase(database string) testcontainers.CustomizeRequestOption

func WithDefaultCredentials

func WithDefaultCredentials() testcontainers.CustomizeRequestOption

WithDefaultCredentials applies the default credentials to the container request. It will look up for MARIADB environment variables.

func WithPassword

func WithPassword(password string) testcontainers.CustomizeRequestOption

func WithScripts

func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption

func WithUsername

func WithUsername(username string) testcontainers.CustomizeRequestOption

Types

type MariaDBContainer

type MariaDBContainer struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

MariaDBContainer represents the MariaDB container type used in the module

func Run added in v0.32.0

func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*MariaDBContainer, error)

Run creates an instance of the MariaDB container type

Example
// runMariaDBContainer {
ctx := context.Background()

mariadbContainer, err := mariadb.Run(ctx,
	"mariadb:11.0.3",
	mariadb.WithConfigFile(filepath.Join("testdata", "my.cnf")),
	mariadb.WithScripts(filepath.Join("testdata", "schema.sql")),
	mariadb.WithDatabase("foo"),
	mariadb.WithUsername("root"),
	mariadb.WithPassword(""),
)
defer func() {
	if err := testcontainers.TerminateContainer(mariadbContainer); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start container: %s", err)
	return
}
// }

state, err := mariadbContainer.State(ctx)
if err != nil {
	log.Printf("failed to get container state: %s", err)
	return
}

fmt.Println(state.Running)
Output:

true

func RunContainer deprecated

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*MariaDBContainer, error)

Deprecated: use Run instead RunContainer creates an instance of the MariaDB container type

func (*MariaDBContainer) ConnectionString

func (c *MariaDBContainer) ConnectionString(ctx context.Context, args ...string) (string, error)

func (*MariaDBContainer) MustConnectionString added in v0.30.0

func (c *MariaDBContainer) MustConnectionString(ctx context.Context, args ...string) string

MustConnectionString panics if the address cannot be determined.

Jump to

Keyboard shortcuts

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