Skip to content

Commit d7656e0

Browse files
committed
Test mirror handling of deleted project
1 parent bd76b4d commit d7656e0

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tests/test_integration.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import stat
33
import subprocess
44
import tempfile
5+
import time
56

67
import requests
8+
from grab import Grab
79

810
import pytest
9-
from grab import Grab
1011

1112

1213
@pytest.fixture(autouse=True)
@@ -155,13 +156,33 @@ def make_project(self, **kwargs):
155156
data = response.json()
156157
return data["id"], self.git_url + data["path_with_namespace"] + ".git"
157158

159+
def delete_project(self, project_id):
160+
"""Make a project and return (id, ssh url)."""
161+
project_url = self.http_url + "api/v4/projects/%s" % project_id
162+
response = self.session.delete(project_url)
163+
# the delete is asynchronus so wait for it
164+
response.raise_for_status()
165+
for _ in range(5):
166+
time.sleep(1)
167+
response = self.session.get(project_url)
168+
if response.status_code == 404:
169+
return
170+
raise Exception("Project not deleted in time.")
171+
158172
yield Info()
159173

160174

161-
def test_smoke(gitlab):
175+
def test_mirror(gitlab):
162176
"""Check that a sync runs first time."""
163177
gitlab_sync = gitlab.make_runner()
164-
gitlab.make_project(name="lulz")
178+
project_id, _ = gitlab.make_project(name="lulz")
179+
gitlab_sync("local-update", check=True)
180+
project_absolute_path = gitlab.sync_root / gitlab.username / "lulz"
181+
assert project_absolute_path.is_dir()
182+
165183
gitlab_sync("local-update", check=True)
166-
assert (gitlab.sync_root / gitlab.username / "lulz").is_dir()
184+
assert project_absolute_path.is_dir()
185+
186+
gitlab.delete_project(project_id)
167187
gitlab_sync("local-update", check=True)
188+
assert not project_absolute_path.is_dir()

0 commit comments

Comments
 (0)