From 92cef0fc3f310c1952ddf82b7f18331f47cdc44d Mon Sep 17 00:00:00 2001 From: yoniebans Date: Thu, 26 Nov 2026 16:59:57 +0100 Subject: [PATCH] test(gateway): cover a busy turn end keeping the move for the next one --- .../test_desktop_project_move_edges.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/gateway/test_desktop_project_move_edges.py b/tests/gateway/test_desktop_project_move_edges.py index 141b88a32f..a0050905ab 100644 --- a/tests/gateway/test_desktop_project_move_edges.py +++ b/tests/gateway/test_desktop_project_move_edges.py @@ -358,3 +358,26 @@ async def test_a_messaging_chat_viewed_in_desktop_is_told_it_did_not_move(tmp_pa assert pdb.get_active_id(conn) == pid finally: await _closed(chat) + + +@pytest.mark.asyncio +async def test_a_busy_boundary_keeps_the_move_for_the_next_one(tmp_path, monkeypatch): + from gateway import session_mutations + from persistence.core.errors import AuthorityRefusal + chat = await _chat(tmp_path, monkeypatch) + try: + assert _move(chat, chat.worktree)['moved'] == 'pending' + write = session_mutations.write_mutation + + async def busy(*args, **kwargs): + monkeypatch.setattr(session_mutations, 'write_mutation', write) + raise AuthorityRefusal('session_busy') + monkeypatch.setattr(session_mutations, 'write_mutation', busy) + await _boundary(chat) # another worker still holds the chat: the move waits + assert chat.authority.sessions[chat.sid].pending_workspace == str(chat.worktree) + assert _policy(chat.authority, chat.sid).cwd == str(chat.start) + await _boundary(chat) + assert _policy(chat.authority, chat.sid).cwd == str(chat.worktree) + assert chat.authority.sessions[chat.sid].pending_workspace is None + finally: + await _closed(chat)