fix: use email probe in JSON export test, format fixes, add requireAdapter skips to Databases VectorsDB/DocumentsDB tests

This commit is contained in:
Prem Palanisamy
2026-04-02 04:39:56 +02:00
parent 8c9f9c6f58
commit 25d9891f2b
10 changed files with 15 additions and 32 deletions
+1 -12
View File
@@ -924,7 +924,7 @@ Http::setResource('getDatabasesDB', function (Group $pools, Cache $cache, Docume
$database->getAdapter()->setSupportForAttributes($databaseType !== DOCUMENTSDB);
// For separate pools (documentsdb/vectorsdb), check their own shared tables config.
// If not configured, fall back to project's shared tables mode.
// If not configured, use dedicated mode to avoid cross-engine tenant type mismatches.
if ($databaseHost !== $dsn->getHost()) {
$dbTypeSharedTables = match ($databaseType) {
DOCUMENTSDB => \array_filter(\explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', ''))),
@@ -937,23 +937,12 @@ Http::setResource('getDatabasesDB', function (Group $pools, Cache $cache, Docume
->setSharedTables(true)
->setTenant($project->getSequence())
->setNamespace($dsn->getParam('namespace'));
} elseif (\in_array($dsn->getHost(), $sharedTables)) {
// No dedicated config — inherit project's shared tables mode
$database
->setSharedTables(true)
->setTenant($project->getSequence())
->setNamespace($dsn->getParam('namespace'));
} else {
$database
->setSharedTables(false)
->setTenant(null)
->setNamespace('_' . $project->getSequence());
}
try {
$database->create();
} catch (\Utopia\Database\Exception\Duplicate) {
}
} elseif (\in_array($dsn->getHost(), $sharedTables)) {
$database
->setSharedTables(true)
+1 -12
View File
@@ -259,7 +259,7 @@ Server::setResource('getDatabasesDB', function (Cache $cache, Registry $register
$sharedTables = \array_filter(\explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')));
// For separate pools (documentsdb/vectorsdb), check their own shared tables config.
// If not configured, fall back to project's shared tables mode.
// If not configured, use dedicated mode to avoid cross-engine tenant type mismatches.
if ($databaseHost !== $dsn->getHost()) {
$dbTypeSharedTables = match ($databaseType) {
DOCUMENTSDB => \array_filter(\explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', ''))),
@@ -272,23 +272,12 @@ Server::setResource('getDatabasesDB', function (Cache $cache, Registry $register
->setSharedTables(true)
->setTenant($projectDocument->getSequence())
->setNamespace($dsn->getParam('namespace'));
} elseif (\in_array($dsn->getHost(), $sharedTables, true)) {
// No dedicated config — inherit project's shared tables mode
$database
->setSharedTables(true)
->setTenant($projectDocument->getSequence())
->setNamespace($dsn->getParam('namespace'));
} else {
$database
->setSharedTables(false)
->setTenant(null)
->setNamespace('_' . $projectDocument->getSequence());
}
try {
$database->create();
} catch (\Utopia\Database\Exception\Duplicate) {
}
} elseif (\in_array($dsn->getHost(), $sharedTables, true)) {
$database
->setSharedTables(true)
@@ -12,11 +12,11 @@ class DocumentsDBConsoleClientTest extends Scope
use DatabasesBase;
use ProjectCustom;
use SideConsole;
use ApiDocumentsDB;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('mongodb');
}
use ApiDocumentsDB;
}
@@ -12,11 +12,11 @@ class DocumentsDBCustomClientTest extends Scope
use DatabasesBase;
use ProjectCustom;
use SideClient;
use ApiDocumentsDB;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('mongodb');
}
use ApiDocumentsDB;
}
@@ -12,11 +12,11 @@ class DocumentsDBCustomServerTest extends Scope
use DatabasesBase;
use ProjectCustom;
use SideServer;
use ApiDocumentsDB;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('mongodb');
}
use ApiDocumentsDB;
}
@@ -16,13 +16,13 @@ class DatabasesPermissionsGuestTest extends Scope
{
use ProjectCustom;
use SideClient;
use DatabasesPermissionsScope;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('postgresql');
}
use DatabasesPermissionsScope;
private $authorization;
@@ -16,13 +16,13 @@ class DatabasesPermissionsMemberTest extends Scope
{
use ProjectCustom;
use SideClient;
use DatabasesPermissionsScope;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('postgresql');
}
use DatabasesPermissionsScope;
public array $collections = [];
@@ -16,13 +16,13 @@ class DatabasesPermissionsTeamTest extends Scope
{
use ProjectCustom;
use SideClient;
use DatabasesPermissionsScope;
protected function setUp(): void
{
parent::setUp();
$this->requireAdapter('postgresql');
}
use DatabasesPermissionsScope;
public array $collections = [];
public string $databaseId = 'testpermissiondb';
@@ -4217,9 +4217,10 @@ trait MigrationsBase
}, 30_000, 500);
// Check that email was sent with download link
$lastEmail = $this->getLastEmail();
$lastEmail = $this->getLastEmail(probe: function ($email) {
$this->assertEquals('Your JSON export is ready', $email['subject']);
});
$this->assertNotEmpty($lastEmail);
$this->assertEquals('Your JSON export is ready', $lastEmail['subject']);
$this->assertStringContainsStringIgnoringCase('Your data export has been completed successfully', $lastEmail['text']);
// Extract download URL from email HTML
@@ -4598,6 +4598,8 @@ class RealtimeCustomClientTest extends Scope
}
public function testChannelDocumentsdb()
{
$this->requireAdapter('mongodb');
$user = $this->getUser();
$session = $user['session'] ?? '';
$projectId = $this->getProject()['$id'];
@@ -5076,6 +5078,8 @@ class RealtimeCustomClientTest extends Scope
public function testChannelVectorsDB()
{
$this->requireAdapter('postgresql');
$user = $this->getUser();
$session = $user['session'] ?? '';
$projectId = $this->getProject()['$id'];