Skip to content

Commit

Permalink
Add test_patroni_logs
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Jul 8, 2024
1 parent a4cb508 commit 0051f49
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/unit/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,15 @@ def test_member_inactive_error(peers_ips, patroni):
assert patroni.member_inactive

_get.assert_called_once_with("http://1.1.1.1:8008/health", verify=True, timeout=5)


def test_patroni_logs(patroni):
with patch("charm.snap.SnapCache") as _snap_cache:
# Test when the logs are returned successfully.
logs = _snap_cache.return_value.__getitem__.return_value.logs
logs.return_value = "fake-logs"
assert patroni.patroni_logs() == "fake-logs"

# Test the charm fails to get the logs.
logs.side_effect = snap.SnapError
assert patroni.patroni_logs() == ""

0 comments on commit 0051f49

Please sign in to comment.