1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:24:03 +00:00

Use randomly generated tenant key instead of 'acme' in failing test (#10)

This commit is contained in:
lukinovec 2023-08-25 17:01:47 +02:00 committed by GitHub
parent 2d500f9780
commit 4d4639450e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,28 +159,23 @@ test('tenancy is initialized when retrying jobs', function (bool $shouldEndTenan
}); });
})->with([true, false]); })->with([true, false]);
// todo0 this test appears to be affected by race conditions/similar
test('the tenant used by the job doesnt change when the current tenant changes', function () { test('the tenant used by the job doesnt change when the current tenant changes', function () {
withTenantDatabases(); withTenantDatabases();
$tenant1 = Tenant::create([ $tenant1 = Tenant::create();
'id' => 'acme',
]);
tenancy()->initialize($tenant1); tenancy()->initialize($tenant1);
dispatch(new TestJob(pest()->valuestore)); dispatch(new TestJob(pest()->valuestore));
$tenant2 = Tenant::create([ $tenant2 = Tenant::create();
'id' => 'foobar',
]);
tenancy()->initialize($tenant2); tenancy()->initialize($tenant2);
expect(pest()->valuestore->has('tenant_id'))->toBeFalse(); expect(pest()->valuestore->has('tenant_id'))->toBeFalse();
pest()->artisan('queue:work --once'); pest()->artisan('queue:work --once');
expect(pest()->valuestore->get('tenant_id'))->toBe('The current tenant id is: acme'); expect(pest()->valuestore->get('tenant_id'))->toBe('The current tenant id is: ' . $tenant1->getTenantKey());
}); });
function createValueStore(): void function createValueStore(): void