🐛 fix: respect DLC_DATABASE_NAME and DLC_DATABASE_SSL_MODE env vars in BDD test server
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 8s
CI/CD Pipeline / CI Pipeline (push) Failing after 4m5s

- Add getDatabaseName() and getDatabaseSSLMode() helper functions
- Update loadConfigFromFile() and createTestConfig() to use these functions
- Fixes CI failure where database name was hardcoded to 'dance_lessons_coach' instead of using 'dance_lessons_coach_bdd_test' from env var

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-04-11 13:43:48 +02:00
parent 70c2eb554e
commit 40967f4e3c

View File

@@ -73,6 +73,24 @@ func getDatabasePort() int {
return port return port
} }
// getDatabaseName returns the database name from environment variable or defaults to dance_lessons_coach
func getDatabaseName() string {
name := os.Getenv("DLC_DATABASE_NAME")
if name == "" {
return "dance_lessons_coach"
}
return name
}
// getDatabaseSSLMode returns the SSL mode from environment variable or defaults to disable
func getDatabaseSSLMode() string {
sslMode := os.Getenv("DLC_DATABASE_SSL_MODE")
if sslMode == "" {
return "disable"
}
return sslMode
}
func init() { func init() {
// Seed the random number generator for random port selection // Seed the random number generator for random port selection
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
@@ -298,8 +316,8 @@ func (s *Server) loadConfigFromFile() (*config.Config, error) {
cfg.Database.Port = getDatabasePort() cfg.Database.Port = getDatabasePort()
cfg.Database.User = "postgres" cfg.Database.User = "postgres"
cfg.Database.Password = "postgres" cfg.Database.Password = "postgres"
cfg.Database.Name = "dance_lessons_coach" cfg.Database.Name = getDatabaseName()
cfg.Database.SSLMode = "disable" cfg.Database.SSLMode = getDatabaseSSLMode()
// Ensure auth defaults // Ensure auth defaults
if cfg.Auth.JWTSecret == "" { if cfg.Auth.JWTSecret == "" {
@@ -668,8 +686,8 @@ func createTestConfig(port int, v2Enabled bool) *config.Config {
Port: getDatabasePort(), Port: getDatabasePort(),
User: "postgres", User: "postgres",
Password: "postgres", Password: "postgres",
Name: "dance_lessons_coach", Name: getDatabaseName(),
SSLMode: "disable", SSLMode: getDatabaseSSLMode(),
}, },
Auth: config.AuthConfig{ Auth: config.AuthConfig{
JWTSecret: "test-secret-key-for-bdd-tests", JWTSecret: "test-secret-key-for-bdd-tests",