Files
navidrome-litefs/scripts/cluster_status/tests/test_config.py

27 lines
948 B
Python

import os
import pytest
import config
def test_default_consul_url():
"""Test that the default Consul URL is returned when no env var is set."""
# Ensure env var is not set
if "CONSUL_HTTP_ADDR" in os.environ:
del os.environ["CONSUL_HTTP_ADDR"]
assert config.get_consul_url() == "http://consul.service.dc1.consul:8500"
def test_env_var_consul_url():
"""Test that the environment variable overrides the default."""
os.environ["CONSUL_HTTP_ADDR"] = "http://10.0.0.1:8500"
try:
assert config.get_consul_url() == "http://10.0.0.1:8500"
finally:
del os.environ["CONSUL_HTTP_ADDR"]
def test_cli_arg_consul_url():
"""Test that the CLI argument overrides everything."""
os.environ["CONSUL_HTTP_ADDR"] = "http://10.0.0.1:8500"
try:
assert config.get_consul_url("http://cli-override:8500") == "http://cli-override:8500"
finally:
del os.environ["CONSUL_HTTP_ADDR"]