mariadb

package module
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 6 Imported by: 1

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 RunContainer

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

RunContainer creates an instance of the MariaDB container type

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

mariadbContainer, err := mariadb.RunContainer(ctx,
	testcontainers.WithImage("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(""),
)
if err != nil {
	log.Fatalf("failed to start container: %s", err)
}

// Clean up the container
defer func() {
	if err := mariadbContainer.Terminate(ctx); err != nil {
		log.Fatalf("failed to terminate container: %s", err)
	}
}()
// }

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

fmt.Println(state.Running)
Output:

true

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