Skip to content

Commit dfc60b3

Browse files
authored
chore: delete topic after creation (#1687)
chore:delete topic after creation part of b/470069573
1 parent 1333c95 commit dfc60b3

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/system/test_notification.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,19 @@ def topic_path(storage_client, topic_name):
6060
@pytest.fixture(scope="session")
6161
def notification_topic(storage_client, publisher_client, topic_path, no_mtls):
6262
_helpers.retry_429(publisher_client.create_topic)(request={"name": topic_path})
63-
policy = publisher_client.get_iam_policy(request={"resource": topic_path})
64-
binding = policy.bindings.add()
65-
binding.role = "roles/pubsub.publisher"
66-
binding.members.append(
67-
f"serviceAccount:{storage_client.get_service_account_email()}"
68-
)
69-
publisher_client.set_iam_policy(request={"resource": topic_path, "policy": policy})
63+
try:
64+
policy = publisher_client.get_iam_policy(request={"resource": topic_path})
65+
binding = policy.bindings.add()
66+
binding.role = "roles/pubsub.publisher"
67+
binding.members.append(
68+
f"serviceAccount:{storage_client.get_service_account_email()}"
69+
)
70+
publisher_client.set_iam_policy(
71+
request={"resource": topic_path, "policy": policy}
72+
)
73+
yield topic_path
74+
finally:
75+
publisher_client.delete_topic(request={"topic": topic_path})
7076

7177

7278
@pytest.mark.skip(reason="until b/470069573 is fixed")

0 commit comments

Comments
 (0)