🐛 fix: BDD tests PostgreSQL connection for native execution
- Enhance getPostgresHost() to detect Docker vs native execution - Use localhost for native execution (PostgreSQL port mapping) - Use container name for Docker execution - Fix local CI/CD script to set correct DLC_DATABASE_HOST - Ensure BDD tests can connect in both Docker and native modes Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -17,14 +17,19 @@ import (
|
||||
)
|
||||
|
||||
// getPostgresHost returns the appropriate PostgreSQL host based on environment
|
||||
// Uses DLC_DATABASE_HOST environment variable or defaults to container name
|
||||
// Uses DLC_DATABASE_HOST environment variable or defaults appropriately
|
||||
func getPostgresHost() string {
|
||||
host := os.Getenv("DLC_DATABASE_HOST")
|
||||
if host != "" {
|
||||
return host
|
||||
}
|
||||
// Default to container name for Docker environments
|
||||
return "dance-lessons-coach-postgres"
|
||||
// Default to localhost for native execution, container name for Docker
|
||||
// Check if we're running in a container by looking for Docker-specific env vars
|
||||
if os.Getenv("DOCKER_CONTAINER") != "" || os.Getenv("KUBERNETES_SERVICE_HOST") != "" {
|
||||
return "dance-lessons-coach-postgres"
|
||||
}
|
||||
// Native execution - use localhost with container port mapping
|
||||
return "localhost"
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
|
||||
Reference in New Issue
Block a user