Skip to content

Commit

Permalink
Ensure that when Harness.remove_relation() is called, the relation is…
Browse files Browse the repository at this point in the history
… treated as-if this was a relation-broken event.
  • Loading branch information
tonyandrewmeyer committed Dec 14, 2023
1 parent cd8416a commit 56b6773
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ops/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,13 @@ def remove_relation(self, relation_id: int) -> None:
for unit_name in rel_list_map[relation_id].copy():
self.remove_relation_unit(relation_id, unit_name)

prev_broken_id = None # Silence linter warning.
if self._model is not None:
prev_broken_id = self._model._relations._broken_relation_id
self._model._relations._broken_relation_id = relation_id
self._emit_relation_broken(relation_name, relation_id, remote_app)
if self._model is not None:
self._model._relations._broken_relation_id = prev_broken_id
self._model.relations._invalidate(relation_name)

self._backend._relation_app_and_units.pop(relation_id)
Expand Down

0 comments on commit 56b6773

Please sign in to comment.