mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
Test that the SQLite DB manager recognizes in-memory DBs
This commit is contained in:
parent
9a9adc0d99
commit
7f93f4460a
1 changed files with 12 additions and 7 deletions
|
|
@ -615,7 +615,7 @@ test('database managers validate parameters that cannot be bound', function ($dr
|
||||||
}
|
}
|
||||||
})->with('database_managers');
|
})->with('database_managers');
|
||||||
|
|
||||||
test('sqlite database manager validates database names', function () {
|
test('sqlite database manager validates database names correctly', function () {
|
||||||
$manager = app(SQLiteDatabaseManager::class);
|
$manager = app(SQLiteDatabaseManager::class);
|
||||||
|
|
||||||
// Dots are allowed in database names
|
// Dots are allowed in database names
|
||||||
|
|
@ -629,14 +629,19 @@ test('sqlite database manager validates database names', function () {
|
||||||
// Empty strings are considered invalid input for database names
|
// Empty strings are considered invalid input for database names
|
||||||
expect(fn () => $manager->databaseExists(''))
|
expect(fn () => $manager->databaseExists(''))
|
||||||
->toThrow(InvalidArgumentException::class);
|
->toThrow(InvalidArgumentException::class);
|
||||||
|
});
|
||||||
|
|
||||||
// In-memory database names have to start with 'file:_tenancy_inmemory_'
|
test('sqlite database manager recognizes inmemory databases correctly', function () {
|
||||||
expect(fn () => $manager->databaseExists('file:_tenancy_inmemory_123?mode=memory&cache=shared'))
|
$manager = app(SQLiteDatabaseManager::class);
|
||||||
->not()->toThrow(InvalidArgumentException::class);
|
|
||||||
|
|
||||||
// Doesn't start with 'file:_tenancy_inmemory_', not considered an in-memory database, filename validation applies
|
expect($manager->isInMemory('file:_tenancy_inmemory_123?mode=memory&cache=shared'))->toBeTrue();
|
||||||
expect(fn () => $manager->databaseExists('../_tenancy_inmemory_'))
|
expect($manager->isInMemory(':memory:'))->toBeTrue();
|
||||||
->toThrow(InvalidArgumentException::class);
|
|
||||||
|
// Missing the '?mode=memory&cache=shared' suffix
|
||||||
|
expect($manager->isInMemory('file:_tenancy_inmemory_456'))->toBeFalse();
|
||||||
|
|
||||||
|
// Doesn't start with 'file:_tenancy_inmemory_'
|
||||||
|
expect($manager->isInMemory('_tenancy_inmemory_123?mode=memory&cache=shared'))->toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Datasets
|
// Datasets
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue