import sys
from typing import NoReturn
import unittest
-from ops.model import ActiveStatus
-from ops.testing import Harness
from charm import PrometheusCharm
+from ops.model import ActiveStatus
+from ops.testing import Harness
class TestCharm(unittest.TestCase):
"max_file_size": 0,
"ingress_whitelist_source_range": "",
"tls_secret_name": "",
- "site_url": "https://prometheus.192.168.100.100.xip.io",
+ "site_url": "https://prometheus.192.168.100.100.nip.io",
+ "cluster_issuer": "vault-issuer",
"enable_web_admin_api": False,
+ "web_config_username": "admin",
+ "web_config_password": "1234",
}
self.harness.update_config(self.config)
) -> NoReturn:
"""Test to see if prometheus relation is updated."""
expected_result = {
- "hostname": "prometheus",
+ "hostname": self.harness.charm.app.name,
"port": "9090",
+ "user": "admin",
+ "password": "1234",
}
relation_id = self.harness.add_relation("prometheus", "mon")
self.harness.add_relation_unit(relation_id, "mon/0")
- relation_data = self.harness.get_relation_data(relation_id, "prometheus")
+ relation_data = self.harness.get_relation_data(
+ relation_id, self.harness.charm.app.name
+ )
self.assertDictEqual(expected_result, relation_data)
self.harness.set_leader(is_leader=False)
relation_id = self.harness.add_relation("prometheus", "mon")
self.harness.add_relation_unit(relation_id, "mon/0")
- relation_data = self.harness.get_relation_data(relation_id, "prometheus")
+ relation_data = self.harness.get_relation_data(
+ relation_id, self.harness.charm.app.name
+ )
self.assertDictEqual(expected_result, relation_data)