🐛 fix: respect DLC_DATABASE_NAME and DLC_DATABASE_SSL_MODE env vars in BDD test server
- 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:
@@ -73,6 +73,24 @@ func getDatabasePort() int {
|
||||
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() {
|
||||
// Seed the random number generator for random port selection
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
@@ -298,8 +316,8 @@ func (s *Server) loadConfigFromFile() (*config.Config, error) {
|
||||
cfg.Database.Port = getDatabasePort()
|
||||
cfg.Database.User = "postgres"
|
||||
cfg.Database.Password = "postgres"
|
||||
cfg.Database.Name = "dance_lessons_coach"
|
||||
cfg.Database.SSLMode = "disable"
|
||||
cfg.Database.Name = getDatabaseName()
|
||||
cfg.Database.SSLMode = getDatabaseSSLMode()
|
||||
|
||||
// Ensure auth defaults
|
||||
if cfg.Auth.JWTSecret == "" {
|
||||
@@ -668,8 +686,8 @@ func createTestConfig(port int, v2Enabled bool) *config.Config {
|
||||
Port: getDatabasePort(),
|
||||
User: "postgres",
|
||||
Password: "postgres",
|
||||
Name: "dance_lessons_coach",
|
||||
SSLMode: "disable",
|
||||
Name: getDatabaseName(),
|
||||
SSLMode: getDatabaseSSLMode(),
|
||||
},
|
||||
Auth: config.AuthConfig{
|
||||
JWTSecret: "test-secret-key-for-bdd-tests",
|
||||
|
||||
Reference in New Issue
Block a user