Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Oct 25, 2023
1 parent 0e02c54 commit bc75919
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ def test_on_install_snap_failure(
_install_snap_packages.assert_called_once()
self.assertTrue(isinstance(self.harness.model.unit.status, BlockedStatus))

@patch_network_get(private_address="1.1.1.1")
def test_patroni_scrape_config_no_tls(self):
result = self.charm.patroni_scrape_config()

assert result == [
{
"metrics_path": "/metrics",
"scheme": "http",
"static_configs": [{"targets": ["localhost:8008"]}],
"static_configs": [{"targets": ["1.1.1.1:8008"]}],
"tls_config": {"insecure_skip_verify": True},
},
]

@patch_network_get(private_address="1.1.1.1")
@patch(
"charm.PostgresqlOperatorCharm.is_tls_enabled",
return_value=True,
Expand All @@ -159,7 +161,7 @@ def test_patroni_scrape_config_tls(self, _):
{
"metrics_path": "/metrics",
"scheme": "https",
"static_configs": [{"targets": ["localhost:8008"]}],
"static_configs": [{"targets": ["1.1.1.1:8008"]}],
"tls_config": {"insecure_skip_verify": True},
},
]
Expand Down Expand Up @@ -1087,6 +1089,7 @@ def test_restart(self, _are_all_members_ready, _restart_postgresql):
mock_event.defer.assert_not_called()

@patch_network_get(private_address="1.1.1.1")
@patch('charm.time.sleep', return_value=None)
@patch("subprocess.check_output", return_value=b"C")
@patch("charm.snap.SnapCache")
@patch("charms.rolling_ops.v0.rollingops.RollingOpsManager._on_acquire_lock")
Expand All @@ -1109,6 +1112,7 @@ def test_update_config(
_restart,
___,
____,
_____,
):
with patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock:
# Mock some properties.
Expand Down

0 comments on commit bc75919

Please sign in to comment.