sqldb/v2: set predictable NewTestPgFixture container name
What changed, and why it matters
This commit changes a test helper that spins up temporary PostgreSQL databases inside Docker containers during automated testing. It gives each container a predictable, test-specific name instead of letting Docker generate a random one. This only affects internal test infrastructure and does not change any production code, user-facing behavior, or network security.
No security action needed. Treat as a normal test-maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In sqldb/v2/postgres_fixture.go, NewTestPgFixture now constructs a deterministic Docker container name from the Go test name (with ‘/’ replaced by ‘_’) and passes it via dockertest.RunOptions.Name. A new sanitizeDockerName helper performs the slash-to-underscore substitution. The change is purely for test hygiene/debugging and is not a security patch.
Changed components
sqldb/v2/postgres_fixture.gointernal test fixture NewTestPgFixtureInspect captured patch +10 / −0
diff --git a/sqldb/v2/postgres_fixture.go b/sqldb/v2/postgres_fixture.go
index 03c9a17..8d653af 100644
--- a/sqldb/v2/postgres_fixture.go
+++ b/sqldb/v2/postgres_fixture.go
@@ -45,8 +45,12 @@ func NewTestPgFixture(t testing.TB, expiry time.Duration) *TestPgFixture {
pool, err := dockertest.NewPool("")
require.NoError(t, err, "Could not connect to docker")
+ // Create a predictable container name.
+ containerName := sanitizeDockerName(t.Name() + "-postgresql-container")
+
// Pulls an image, creates a container based on it and runs it.
resource, err := pool.RunWithOptions(&dockertest.RunOptions{
+ Name: containerName,
Repository: "postgres",
Tag: PostgresTag,
Env: []string{
@@ -108,6 +112,12 @@ func NewTestPgFixture(t testing.TB, expiry time.Duration) *TestPgFixture {
return fixture
}
+// sanitizeDockerName returns a Docker-safe container name by replacing
+// disallowed path separators ("/") with underscores.
+func sanitizeDockerName(name string) string {
+ return strings.ReplaceAll(name, "/", "_")
+}
+
// GetConfig returns the full config of the Postgres node.
func (f *TestPgFixture) GetConfig(dbName string) *PostgresConfig {
return &PostgresConfig{
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.