mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-08 05:18:49 +03:00
feat(config): add actionable startup diagnostics and WebUI recovery (#5110)
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.config.errors import ConfigLoadError
|
||||
from nanobot.config.loader import (
|
||||
_resolve_env_vars,
|
||||
load_config,
|
||||
@@ -66,6 +67,22 @@ class TestResolveConfig:
|
||||
resolved = resolve_config_env_vars(raw)
|
||||
assert resolved.providers.groq.api_key == "resolved-key"
|
||||
|
||||
def test_missing_env_var_reports_config_field(self, tmp_path, monkeypatch):
|
||||
name = "NANOBOT_TEST_MISSING_PROVIDER_KEY"
|
||||
monkeypatch.delenv(name, raising=False)
|
||||
config_path = tmp_path / "config.json"
|
||||
config = Config.model_validate(
|
||||
{"providers": {"openrouter": {"apiKey": f"${{{name}}}"}}}
|
||||
)
|
||||
|
||||
with pytest.raises(ConfigLoadError) as exc_info:
|
||||
resolve_config_env_vars(config, config_path=config_path)
|
||||
|
||||
error = exc_info.value
|
||||
assert error.kind == "missing_env"
|
||||
assert "providers.openrouter.apiKey" in str(error)
|
||||
assert name in str(error)
|
||||
|
||||
def test_save_preserves_templates(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("MY_TOKEN", "real-token")
|
||||
config_path = tmp_path / "config.json"
|
||||
|
||||
Reference in New Issue
Block a user