Skip to content

Commit 4713f4e

Browse files
committed
test: skip deletion of descendant groups in reset_gitlab
1 parent 40aa5bd commit 4713f4e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/functional/conftest.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,16 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
9898
full_paths = [group.full_path for group in gl.groups.list()]
9999
logging.info(f"Groups to be deleted: {full_paths}")
100100
for group in gl.groups.list():
101-
logging.info(f"Current group: {group.full_path!r}, group_id: {group.get_id()}")
102-
descendant_full_paths = [
103-
group.full_path
104-
for group in group.descendant_groups.list(order_by="id", sort="desc")
105-
]
106-
logging.info(f"Descendant groups to be deleted: {descendant_full_paths}")
107-
for descendant_group in group.descendant_groups.list(
108-
order_by="id", sort="desc"
109-
):
101+
102+
# skip deletion of a descendant group to prevent scenarios where parent group gets deleted leaving a dangling descendant whose deletion will throw 404s.
103+
# descendant groups cannot contain the `/` special character: https://docs.gitlab.com/ee/user/reserved_names.html#limitations-on-project-and-group-names
104+
if "/" in group.full_path:
110105
logging.info(
111-
f"Current group: {descendant_group.full_path!r}, group_id: {descendant_group.get_id()}"
106+
f"Skipping deletion of {group.full_path} as it is a descendant group"
112107
)
113-
logging.info(f"Deleting descendant group: {descendant_group.full_path!r}")
114-
helpers.safe_delete(descendant_group)
108+
continue
109+
110+
logging.info(f"Current group: {group.full_path!r}, group_id: {group.get_id()}")
115111
for deploy_token in group.deploytokens.list():
116112
logging.info(
117113
f"Deleting deploy token: {deploy_token.username!r} in "

0 commit comments

Comments
 (0)