coolify/tests/Unit/PostgRESTDetectionTest.php
Andras Bacsai dd9ea00914 Fix PostgREST misclassification and empty Domains section
- Replace substring matching with exact base image name comparison in isDatabaseImage() to prevent false positives (postgres no longer matches postgrest)
- Add 'timescaledb' and 'timescaledb-ha' to DATABASE_DOCKER_IMAGES constants for proper namespace handling
- Add empty state messaging when no applications are defined in Docker Compose configuration
- Maintain backward compatibility with all existing database patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 16:52:09 +01:00

74 lines
2.2 KiB
PHP

<?php
test('postgrest image is detected as application not database', function () {
$result = isDatabaseImage('postgrest/postgrest:latest');
expect($result)->toBeFalse();
});
test('postgrest image with version is detected as application', function () {
$result = isDatabaseImage('postgrest/postgrest:v12.0.2');
expect($result)->toBeFalse();
});
test('postgrest with registry prefix is detected as application', function () {
$result = isDatabaseImage('ghcr.io/postgrest/postgrest:latest');
expect($result)->toBeFalse();
});
test('regular postgres image is still detected as database', function () {
$result = isDatabaseImage('postgres:15');
expect($result)->toBeTrue();
});
test('postgres with registry prefix is detected as database', function () {
$result = isDatabaseImage('docker.io/library/postgres:15');
expect($result)->toBeTrue();
});
test('postgres image with service config is detected correctly', function () {
$serviceConfig = [
'image' => 'postgres:15',
'environment' => [
'POSTGRES_PASSWORD=secret',
],
];
$result = isDatabaseImage('postgres:15', $serviceConfig);
expect($result)->toBeTrue();
});
test('postgrest without service config is still detected as application', function () {
$result = isDatabaseImage('postgrest/postgrest', null);
expect($result)->toBeFalse();
});
test('supabase postgres-meta is detected as application', function () {
$result = isDatabaseImage('supabase/postgres-meta:latest');
expect($result)->toBeFalse();
});
test('mysql image is detected as database', function () {
$result = isDatabaseImage('mysql:8.0');
expect($result)->toBeTrue();
});
test('redis image is detected as database', function () {
$result = isDatabaseImage('redis:7');
expect($result)->toBeTrue();
});
test('timescale timescaledb is detected as database', function () {
$result = isDatabaseImage('timescale/timescaledb:latest');
expect($result)->toBeTrue();
});
test('mariadb is detected as database', function () {
$result = isDatabaseImage('mariadb:10.11');
expect($result)->toBeTrue();
});
test('mongodb is detected as database', function () {
$result = isDatabaseImage('mongo:7');
expect($result)->toBeTrue();
});