Files
wehub-resource-sync 75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:11:07 +08:00

58 lines
1.7 KiB
Go

package containers
import (
"testing"
"github.com/testcontainers/testcontainers-go"
)
// Credentials baked into every test MariaDB container.
const (
MariadbRootPassword = "rootpassword"
MariadbUsername = "testuser"
MariadbPassword = "testpassword"
MariadbDatabase = "testdb"
)
const mariadbPort = "3306/tcp"
func mariadbEnv() map[string]string {
return map[string]string{
"MARIADB_ROOT_PASSWORD": MariadbRootPassword,
"MARIADB_DATABASE": MariadbDatabase,
"MARIADB_USER": MariadbUsername,
"MARIADB_PASSWORD": MariadbPassword,
}
}
// mariadbRequest builds the container request for image (e.g. "mariadb:10.11"). MariaDB runs the
// shared MySQL-family server flags (mysqlFamilyCmd) unchanged.
func mariadbRequest(image string) testcontainers.ContainerRequest {
return testcontainers.ContainerRequest{
Image: image,
ExposedPorts: []string{mariadbPort},
Env: mariadbEnv(),
Cmd: mysqlFamilyCmd(),
Tmpfs: map[string]string{"/var/lib/mysql": dataDirTmpfsOptions},
WaitingFor: mysqlFamilyReady(mariadbPort),
}
}
// StartMariadb boots a MariaDB server from image (e.g. "mariadb:10.11").
func StartMariadb(t *testing.T, image string) Endpoint {
t.Helper()
return start(t, mariadbRequest(image), mariadbPort)
}
// StartMariadbSSL boots a MariaDB server that rejects unencrypted connections. The image
// auto-generates its server certificates, so the test connects with tlsInsecure and no client cert.
func StartMariadbSSL(t *testing.T, image string) Endpoint {
t.Helper()
req := mariadbRequest(image)
req.Cmd = append(req.Cmd, "--require-secure-transport=ON")
return start(t, req, mariadbPort)
}