Skip to content

Commit

Permalink
test: test unhappy path in extra_listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoppenheimer committed Nov 8, 2024
1 parent 1e4bb90 commit afe65a7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest
import yaml
from ops.testing import Harness
from pydantic import ValidationError

from charm import KafkaCharm
from literals import (
Expand Down Expand Up @@ -161,6 +162,21 @@ def test_listeners_in_server_properties(harness: Harness[KafkaCharm]):

def test_extra_listeners_in_server_properties(harness: Harness[KafkaCharm]):
"""Checks that the extra-listeners are properly set from config."""
# verifying structured config validators
for value in [
"missing.port",
"low.port:15000",
"high.port:60000",
"non.unique:30000,other.non.unique:30000",
"close.port:30000,other.close.port:30001",
]:
with pytest.raises(ValidationError):
harness._update_config(
{"extra_listeners": value}
# {"extra_listeners": "worker-{unit}.foo.com:30000,worker-{unit}.bar.com:40000"}
)
harness.charm.broker.config_manager.config = harness.charm.config

harness._update_config(
{"extra_listeners": "worker-{unit}.foo.com:30000,worker-{unit}.bar.com:40000"}
)
Expand Down

0 comments on commit afe65a7

Please sign in to comment.