fix migration test
CI / lint-backend (push) Successful in 1m22s
CI / lint-mobile (push) Successful in 8m21s
CI / test-backend (push) Successful in 1m16s
CI / test-mobile (push) Successful in 8m34s
CI / build-backend (push) Failing after 58s
CI / docker (push) Skipped

This commit is contained in:
m
2026-09-19 20:05:08 +02:00
parent d52460834a
commit 5a452c46af
3 changed files with 80 additions and 13 deletions
+4 -8
View File
@@ -4,7 +4,6 @@ import (
"database/sql"
"fmt"
"net/url"
"os"
"strings"
"testing"
@@ -16,19 +15,16 @@ import (
// OpenTestDatabase ensures the test database exists, resets its schema, runs
// all migrations, and returns a live connection (closed via t.Cleanup).
// Tests are skipped only when Postgres itself is unreachable. `databaseURL`
// empty falls back to TEST_DATABASE_URL, then to the global default.
// empty falls back to the global default. TEST_DATABASE_URL (CI) n'override
// que l'endpoint (hôte/creds) : le nom de base propre au package est
// préservé, pour que les packages parallèles ne partagent jamais un schéma.
func OpenTestDatabase(t *testing.T, databaseURL string) *sql.DB {
t.Helper()
switch {
case databaseURL == "":
databaseURL = os.Getenv("TEST_DATABASE_URL")
case os.Getenv("TEST_DATABASE_URL") != "":
databaseURL = os.Getenv("TEST_DATABASE_URL")
}
if databaseURL == "" {
databaseURL = "postgres://kazier:kazier@localhost:5432/kazier_test?sslmode=disable"
}
databaseURL = db.TestDatabaseURL(databaseURL)
// Postgres joignable ? (sinon on skippe, sans être gênés par l'existence
// ou non de la base cible)