Skip to content

Commit a854882

Browse files
committed
fixup! Convert branch deletion to celery job
1 parent ac636e0 commit a854882

2 files changed

Lines changed: 30 additions & 86 deletions

File tree

tests/branches/test_basic.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import psycopg
44
import pytest
5-
from conftest import BRANCH_TIMEOUT_SEC, wait_for_status
5+
from conftest import BRANCH_TIMEOUT_SEC, wait_for_deletion, wait_for_status
66

77
pytestmark = pytest.mark.branch
88

@@ -182,3 +182,32 @@ def test_branch_apikey_list(client, org, project, branch_id):
182182
assert r.status_code == 200
183183
ids = [k["id"] for k in r.json()]
184184
assert _state["api_key_id"] in ids
185+
186+
187+
def test_branch_delete_lifecycle(client, org, project, branch_id):
188+
base = f"organizations/{org}/projects/{project}/branches/{branch_id}"
189+
190+
# DELETE returns 202 with a Location pointing at the task
191+
r = client.delete(f"{base}/")
192+
assert r.status_code == 202
193+
assert "Location" in r.headers
194+
195+
# Branch detail reflects the DELETING status immediately
196+
r = client.get(f"{base}/")
197+
if r.status_code == 200:
198+
assert r.json()["status"] == "DELETING"
199+
200+
# Task is listed on the branch while deletion is in progress
201+
r = client.get(f"{base}/tasks/")
202+
if r.status_code == 200:
203+
assert any(t["task_type"] == "delete" for t in r.json())
204+
205+
# A second DELETE while delete_task_id is set must be rejected
206+
r = client.delete(f"{base}/")
207+
assert r.status_code == 400
208+
209+
# Wait for the background job to finish — branch must disappear
210+
wait_for_deletion(client, f"{base}/", BRANCH_TIMEOUT_SEC)
211+
212+
r = client.get(f"{base}/")
213+
assert r.status_code == 404

tests/branches/test_delete.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)