Skip to content

Commit c1cbf5a

Browse files
test(review): cover workspace ownership race
1 parent 11ced96 commit c1cbf5a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_service.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,25 @@ def test_conflict_review_hides_another_callers_session_memory():
831831
set_current_user(None)
832832

833833

834+
def test_first_use_workspace_rechecks_personal_owner_after_atomic_race(monkeypatch):
835+
service = MemoryService.create(':memory:')
836+
try:
837+
set_current_user({'id': 'usr_alice', 'email': 'alice@example.test', 'role': 'member'})
838+
winner_id = service.store.create_workspace(
839+
'raced', settings={'visibility': 'personal', 'owner': 'bob@example.test'},
840+
)
841+
842+
def return_racing_winner(_name, *, settings=None):
843+
del settings
844+
return winner_id
845+
846+
monkeypatch.setattr(service.store, 'get_or_create_workspace', return_racing_winner)
847+
with pytest.raises(ValidationError, match='personal folder of another user'):
848+
service.remember('must not enter the raced workspace', workspace='raced')
849+
finally:
850+
set_current_user(None)
851+
852+
834853
def test_conflict_review_pages_past_ineligible_newer_rows_before_limit():
835854
service = MemoryService.create(":memory:")
836855
wid = service.store.get_or_create_workspace("acme")

0 commit comments

Comments
 (0)