@@ -63,8 +63,9 @@ def __enter__(self):
63
63
def __exit__ (self , type , value , traceback ):
64
64
# Delete the policy and channel we created.
65
65
self .alert_policy_client .delete_alert_policy (self .alert_policy .name )
66
- self .notification_channel_client .delete_notification_channel (
67
- self .notification_channel .name )
66
+ if self .notification_channel .name :
67
+ self .notification_channel_client .delete_notification_channel (
68
+ self .notification_channel .name )
68
69
69
70
70
71
@pytest .fixture (scope = 'session' )
@@ -114,3 +115,12 @@ def test_backup_and_restore(capsys, pochan):
114
115
assert "Updated {0}" .format (pochan .alert_policy .name ) in out
115
116
assert "Updating channel {0}" .format (
116
117
pochan .notification_channel .display_name ) in out
118
+
119
+
120
+ def test_delete_channels (capsys , pochan ):
121
+ notification_channel_id = pochan .notification_channel .name .split ('/' )[- 1 ]
122
+ snippets .delete_notification_channels (
123
+ pochan .project_name , [notification_channel_id ], force = True )
124
+ out , _ = capsys .readouterr ()
125
+ assert "{0} deleted" .format (notification_channel_id ) in out
126
+ pochan .notification_channel .name = '' # So teardown is not tried
0 commit comments