Skip to content

Commit

Permalink
Fix RemoteConfigurationRequirer tests on ops 2.0.0 (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt authored Jan 17, 2023
1 parent 20b203d commit 66ab949
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/unit/test_remote_configuration_requirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ def setUp(self, _) -> None:
self.harness = testing.Harness(AlertmanagerCharm)
self.addCleanup(self.harness.cleanup)
self.harness.set_leader(True)

# TODO: Once we're on ops 2.0.0+ this can be removed as begin_with_initial_hooks()
# now does it.
self.harness.set_can_connect("alertmanager", True)

# In ops 2.0.0+, we need to mock the version, as begin_with_initial_hooks() now triggers
# pebble-ready, which attempts to obtain the workload version.
patcher = patch.object(
AlertmanagerCharm, "_alertmanager_version", property(lambda *_: "0.0.0")
)
self.mock_version = patcher.start()
self.addCleanup(patcher.stop)

self.harness.begin_with_initial_hooks()

self.relation_id = self.harness.add_relation(
Expand Down

0 comments on commit 66ab949

Please sign in to comment.