Skip to content

Commit 9c25598

Browse files
committed
Add debug logging to TestMain to diagnose why MYSQL_ENDPOINT is not set
Add logging to verify TestMain is running and that environment variables are being set. This will help diagnose why tests are failing.
1 parent 0504a5f commit 9c25598

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mysql/testcontainers_testmain.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ func TestMain(m *testing.M) {
2323
os.Exit(1)
2424
}
2525

26+
// Debug: Log that TestMain is running
27+
os.Stderr.WriteString(fmt.Sprintf("TestMain: Starting with DOCKER_IMAGE='%s'\n", dockerImage))
28+
2629
// Check if we're testing TiDB (format: tidb:VERSION)
2730
// TiDB requires multi-container setup
2831
if strings.HasPrefix(dockerImage, "tidb:") {
@@ -78,6 +81,8 @@ func TestMain(m *testing.M) {
7881
os.Setenv("MYSQL_ENDPOINT", sharedContainer.Endpoint)
7982
os.Setenv("MYSQL_USERNAME", sharedContainer.Username)
8083
os.Setenv("MYSQL_PASSWORD", sharedContainer.Password)
84+
// Debug: Log that environment variables are set
85+
os.Stderr.WriteString(fmt.Sprintf("TestMain: Set MYSQL_ENDPOINT='%s'\n", sharedContainer.Endpoint))
8186
} else {
8287
// This should never happen, but if it does, fail loudly
8388
os.Stderr.WriteString(fmt.Sprintf("ERROR: startSharedMySQLContainer returned nil container without error for image '%s'\n", dockerImage))

0 commit comments

Comments
 (0)