Skip to content

Commit f82e69a

Browse files
committed
Fix getSharedMySQLContainer validation - check for TiDB mode first
Add check to ensure getSharedMySQLContainer isn't called during TiDB tests. This prevents DOCKER_IMAGE validation errors when TIDB_VERSION is set.
1 parent b7ec7f8 commit f82e69a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mysql/testcontainers_helper.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ func contains(s, substr string) bool {
163163
// The image parameter is ignored - TestMain uses DOCKER_IMAGE env var
164164
// This function validates that DOCKER_IMAGE is set and fails early if not
165165
func getSharedMySQLContainer(t *testing.T, image string) *MySQLTestContainer {
166-
// Validate that DOCKER_IMAGE is set (required by TestMain)
166+
// Check if we're in TiDB mode - if so, this function shouldn't be called
167+
tidbVersion := os.Getenv("TIDB_VERSION")
168+
if tidbVersion != "" {
169+
t.Fatalf("ERROR: getSharedMySQLContainer called but TIDB_VERSION is set. " +
170+
"TiDB tests should use the shared TiDB cluster from TestMain, not getSharedMySQLContainer.")
171+
}
172+
173+
// Validate that DOCKER_IMAGE is set (required by TestMain for MySQL/Percona/MariaDB)
167174
dockerImage := os.Getenv("DOCKER_IMAGE")
168175
if dockerImage == "" {
169176
t.Fatalf("ERROR: DOCKER_IMAGE environment variable is not set. This is required for MySQL/Percona/MariaDB tests.\n" +

0 commit comments

Comments
 (0)