Skip to content

Commit e5234da

Browse files
committed
Improve wording, add comments in the pull rollback test
1 parent 698589e commit e5234da

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/PendingTenantsTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@
153153
expect(Tenant::onlyPending()->count())->toBe(0); // Both tenants claimed
154154
});
155155

156-
test('a failed attribute write rolls back the claim and leaves the tenant pending', function () {
157-
// The claim and the attribute write share one transaction, so if applying the attributes
158-
// fails the claim must roll back and the tenant must stay in the pool.
156+
test('the pull is rolled back and the tenant stays in the pool if setting attributes fails', function () {
157+
// Pulling a tenant and setting its attributes happen in one transaction,
158+
// so if setting the attributes fails, the whole pull rolls back and the tenant stays in the pool.
159159
Schema::table('tenants', function (Blueprint $table) {
160160
$table->string('slug')->nullable()->unique();
161161
});
@@ -165,9 +165,11 @@
165165
Tenant::create(['slug' => 'taken']);
166166
Tenant::createPending();
167167

168+
// During the pull, set slug to 'taken', which is already used by another tenant to make the attribute update throw
168169
expect(fn () => Tenant::pullPendingFromPool(false, ['slug' => 'taken']))
169170
->toThrow(QueryException::class);
170171

172+
// The pull rolled back, so the tenant is still pending
171173
expect(Tenant::onlyPending()->count())->toBe(1);
172174
});
173175

0 commit comments

Comments
 (0)