Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Oct 12, 2023
1 parent dd08d7c commit c633b35
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,3 +1408,19 @@ def test_get_available_memory(self):

with patch("builtins.open", mock_open(read_data="")):
self.assertEqual(self.charm.get_available_memory(), 0)

@patch("charm.ClusterTopologyObserver")
@patch("charm.JujuVersion")
def test_juju_run_exec_divergence(self, _juju_version: Mock, _topology_observer: Mock):
# Juju 2
_juju_version.from_environ.return_value.major = 2
harness = Harness(PostgresqlOperatorCharm)
harness.begin()
_topology_observer.assert_called_once_with(harness.charm, "/usr/bin/juju-run")
_topology_observer.reset_mock()

# Juju 3
_juju_version.from_environ.return_value.major = 3
harness = Harness(PostgresqlOperatorCharm)
harness.begin()
_topology_observer.assert_called_once_with(harness.charm, "/usr/bin/juju-exec")

0 comments on commit c633b35

Please sign in to comment.