Fix location of HISHTORY_COMPOSE_TEST var

This commit is contained in:
David Dworken 2024-09-01 14:28:32 -07:00
parent 7dc0fffa4a
commit 42f9df9fcc
No known key found for this signature in database
2 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,6 @@ services:
POSTGRES_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE POSTGRES_PASSWORD: TODO_YOUR_POSTGRES_PASSWORD_HERE
POSTGRES_DB: hishtory POSTGRES_DB: hishtory
PGDATA: /var/lib/postgresql/data/pgdata PGDATA: /var/lib/postgresql/data/pgdata
HISHTORY_COMPOSE_TEST: $HISHTORY_COMPOSE_TEST
volumes: volumes:
- postgres-data:/var/lib/postgresql/data - postgres-data:/var/lib/postgresql/data
healthcheck: healthcheck:
@ -42,6 +41,7 @@ services:
delay: 3s delay: 3s
environment: environment:
HISHTORY_POSTGRES_DB: postgresql://postgres:TODO_YOUR_POSTGRES_PASSWORD_HERE@postgres:5432/hishtory?sslmode=disable HISHTORY_POSTGRES_DB: postgresql://postgres:TODO_YOUR_POSTGRES_PASSWORD_HERE@postgres:5432/hishtory?sslmode=disable
HISHTORY_COMPOSE_TEST: $HISHTORY_COMPOSE_TEST
ports: ports:
- 80:8080 - 80:8080
volumes: volumes:

View File

@ -102,6 +102,7 @@ func OpenDB() (*database.DB, error) {
} }
if os.Getenv("HISHTORY_COMPOSE_TEST") != "" { if os.Getenv("HISHTORY_COMPOSE_TEST") != "" {
// Run an extra round of migrations to test the migration code path to prevent issues like #241 // Run an extra round of migrations to test the migration code path to prevent issues like #241
fmt.Println("AutoMigrating DB tables a second time for test coverage")
err := db.AddDatabaseTables() err := db.AddDatabaseTables()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create underlying DB tables: %w", err) return nil, fmt.Errorf("failed to create underlying DB tables: %w", err)