mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 09:04:03 +00:00
Add Postgres tests
This commit is contained in:
parent
39fe252ef6
commit
dd4013c998
1 changed files with 44 additions and 0 deletions
44
tests/PostgresTest.php
Normal file
44
tests/PostgresTest.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Stancl\Tenancy\Jobs\CreatePostgresUserForTenant;
|
||||
use Stancl\Tenancy\Jobs\DeleteTenantsPostgresUser;
|
||||
|
||||
beforeEach(function () {
|
||||
DB::setDefaultConnection('pgsql');
|
||||
});
|
||||
|
||||
test('postgres user can get created using the job', function() {
|
||||
$tenant = Tenant::create();
|
||||
$name = $tenant->getTenantKey();
|
||||
|
||||
$tenantHasPostgresUser = count(DB::select("SELECT usename FROM pg_user WHERE usename = '$name';")) > 0;
|
||||
|
||||
expect($tenantHasPostgresUser)->toBeFalse();
|
||||
|
||||
CreatePostgresUserForTenant::dispatchSync($tenant);
|
||||
|
||||
expect($tenantHasPostgresUser)->toBeTrue();
|
||||
});
|
||||
|
||||
|
||||
test('postgres user can get deleted using the job', function() {
|
||||
$tenant = Tenant::create();
|
||||
$name = $tenant->getTenantKey();
|
||||
CreatePostgresUserForTenant::dispatchSync($tenant);
|
||||
|
||||
$tenantHasPostgresUser = count(DB::select("SELECT usename FROM pg_user WHERE usename = '$name';")) > 0;
|
||||
|
||||
expect($tenantHasPostgresUser)->toBeTrue();
|
||||
|
||||
DeleteTenantsPostgresUser::dispatchSync($tenant);
|
||||
|
||||
expect($tenantHasPostgresUser)->toBeFalse();
|
||||
});
|
||||
|
||||
test('correct rls policies get created using the command', function() {
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue