From 5e711fbfeb25cb4abad1e20d48413dde03d1269d Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 7 Oct 2025 20:44:36 +0200 Subject: [PATCH] fix(tests): update Docker command for running feature tests without `-it` flag - Removed the `-it` flag from the Docker command used to run feature tests, simplifying the command for users. - Ensured consistency across documentation regarding the execution of database-dependent tests within the Docker container. --- .cursor/rules/testing-patterns.mdc | 2 +- CLAUDE.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.cursor/rules/testing-patterns.mdc b/.cursor/rules/testing-patterns.mdc index f2133c0ac..8d250b56a 100644 --- a/.cursor/rules/testing-patterns.mdc +++ b/.cursor/rules/testing-patterns.mdc @@ -23,7 +23,7 @@ Coolify employs **comprehensive testing strategies** using modern PHP testing fr #### Feature Tests (`tests/Feature/`) - **MAY** use database connections (factories, migrations, models) -- **MUST** run inside Docker container: `docker exec -it coolify php artisan test` +- **MUST** run inside Docker container: `docker exec coolify php artisan test` - **MUST** use `RefreshDatabase` trait if touching database - Purpose: Test API endpoints, workflows, and integration scenarios diff --git a/CLAUDE.md b/CLAUDE.md index b190a9c05..6c594955c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,7 +31,7 @@ ### Code Quality ### Running Tests **IMPORTANT**: Tests that require database connections MUST be run inside the Docker container: -- **Inside Docker**: `docker exec -it coolify php artisan test` (for feature tests requiring database) +- **Inside Docker**: `docker exec coolify php artisan test` (for feature tests requiring database) - **Outside Docker**: `./vendor/bin/pest tests/Unit` (for pure unit tests without database dependencies) - Unit tests should use mocking and avoid database connections - Feature tests that require database must be run in the `coolify` container @@ -187,7 +187,7 @@ ### Testing Strategy #### Test Execution Environment **CRITICAL**: Database-dependent tests MUST run inside Docker container: - **Unit Tests** (`tests/Unit/`): Should NOT use database. Use mocking. Run with `./vendor/bin/pest tests/Unit` -- **Feature Tests** (`tests/Feature/`): May use database. MUST run inside Docker with `docker exec -it coolify php artisan test` +- **Feature Tests** (`tests/Feature/`): May use database. MUST run inside Docker with `docker exec coolify php artisan test` - If a test needs database (factories, migrations, etc.), it belongs in `tests/Feature/` - Always mock external services and SSH connections in tests @@ -591,9 +591,9 @@ ### Running Tests - These tests use mocking and don't require PostgreSQL **Feature Tests (with database):** -- Run inside Docker: `docker exec -it coolify php artisan test` -- Run specific file: `docker exec -it coolify php artisan test tests/Feature/ExampleTest.php` -- Filter by name: `docker exec -it coolify php artisan test --filter=testName` +- Run inside Docker: `docker exec coolify php artisan test` +- Run specific file: `docker exec coolify php artisan test tests/Feature/ExampleTest.php` +- Filter by name: `docker exec coolify php artisan test --filter=testName` - These tests require PostgreSQL and use factories/migrations **General Guidelines:** @@ -696,7 +696,7 @@ ## Test Enforcement - Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass. - Run the minimum number of tests needed to ensure code quality and speed. - **For Unit tests**: Use `./vendor/bin/pest tests/Unit/YourTest.php` (runs outside Docker) -- **For Feature tests**: Use `docker exec -it coolify php artisan test --filter=YourTest` (runs inside Docker) +- **For Feature tests**: Use `docker exec coolify php artisan test --filter=YourTest` (runs inside Docker) - Choose the correct test type based on database dependency: - No database needed? → Unit test with mocking - Database needed? → Feature test in Docker