From 4eab27e1f053816ef55932367fc4f9bb77e2b345 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 24 Apr 2023 17:04:09 +0200 Subject: [PATCH] Add Postgres to db connections and docker-compose --- docker-compose.yml | 21 +++++++++++++++------ tests/TestCase.php | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 465b36cd..43cb3d5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -52,16 +52,25 @@ services: timeout: 10s retries: 10 postgres: - image: postgres:11 + image: 'postgres:15' + ports: + - '${FORWARD_DB_PORT:-5433}:5433' environment: - POSTGRES_PASSWORD: password - POSTGRES_USER: root # superuser name + PGPASSWORD: '${DB_PASSWORD:-password}:password' POSTGRES_DB: main + POSTGRES_USER: '${DB_USERNAME:-root}:root' + POSTGRES_PASSWORD: '${DB_PASSWORD:-password}:password' healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] - interval: 10s + test: + - CMD + - pg_isready + - '-q' + - '-d' + - '${DB_DATABASE}' + - '-U' + - '${DB_USERNAME}' + retries: 3 timeout: 5s - retries: 5 redis: image: redis:alpine healthcheck: diff --git a/tests/TestCase.php b/tests/TestCase.php index 20ecdfee..77b9ca4c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -84,6 +84,20 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], + 'database.connections.pgsql' => [ + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => 'postgres', + 'port' => env('DB_PORT', '5433'), + 'database' => 'main', + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + 'search_path' => 'public', + 'sslmode' => 'prefer', + ], 'database.connections.sqlite.database' => ':memory:', 'database.connections.mysql.host' => env('TENANCY_TEST_MYSQL_HOST', '127.0.0.1'), 'database.connections.sqlsrv.username' => env('TENANCY_TEST_SQLSRV_USERNAME', 'sa'),