🐛 fix: BDD tests PostgreSQL connection using DLC_* environment variables

- Add getPostgresHost() function to use DLC_DATABASE_HOST env var
- Default to dance-lessons-coach-postgres container name
- Update local CI/CD script to set proper DLC_* environment variables
- Fix Docker Compose test execution to pass correct database config
- Ensure BDD tests can connect to PostgreSQL in both Docker and native modes

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-04-07 23:38:27 +02:00
parent f54c60c6a3
commit 9528b7d288
2 changed files with 41 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"net/http"
"os"
"strings"
"time"
@@ -15,6 +16,17 @@ import (
"github.com/rs/zerolog/log"
)
// getPostgresHost returns the appropriate PostgreSQL host based on environment
// Uses DLC_DATABASE_HOST environment variable or defaults to container name
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"
}
type Server struct {
httpServer *http.Server
port int
@@ -260,7 +272,7 @@ func createTestConfig(port int) *config.Config {
AdminMasterPassword: "admin123",
},
Database: config.DatabaseConfig{
Host: "localhost",
Host: getPostgresHost(), // Use container name in Docker, localhost otherwise
Port: 5432,
User: "postgres",
Password: "postgres",