refactor: move all server config to startup env vars; drop plugin settings

This commit is contained in:
tao.chen
2026-07-23 13:21:31 +08:00
parent ca2281af3b
commit f9b93906c6
7 changed files with 72 additions and 171 deletions
+8 -5
View File
@@ -17,21 +17,23 @@ def test_env_url_overrides_default(monkeypatch) -> None:
assert config.url == "http://x:1"
def test_jupyter_settings_override_env(monkeypatch) -> None:
def test_jupyter_settings_are_ignored(monkeypatch) -> None:
monkeypatch.setenv("OPENCODE_BRIDGE_URL", "http://x:1")
settings = {"opencode_bridge": {"opencodeServerUrl": "http://y:2"}}
config = resolve_config(settings)
assert config.url == "http://y:2"
assert config.url == "http://x:1"
def test_all_env_vars(monkeypatch) -> None:
monkeypatch.setenv("OPENCODE_BRIDGE_URL", "http://x:1")
monkeypatch.setenv("OPENCODE_BRIDGE_USER", "u")
monkeypatch.setenv("OPENCODE_BRIDGE_PASSWORD", "p")
monkeypatch.setenv("OPENCODE_BRIDGE_TIMEOUT", "300")
config = resolve_config({})
assert config.url == "http://x:1"
assert config.user == "u"
assert config.password == "p"
assert config.request_timeout_seconds == 300
def test_auth_none_when_password_empty() -> None:
@@ -44,11 +46,12 @@ def test_auth_when_password_set() -> None:
url="http://127.0.0.1:4096",
user="opencode",
password="secret",
request_timeout_seconds=120,
)
assert config.auth == ("opencode", "secret")
def test_request_timeout_from_settings() -> None:
settings = {"opencode_bridge": {"requestTimeoutSeconds": 300}}
config = resolve_config(settings)
def test_request_timeout_from_env(monkeypatch) -> None:
monkeypatch.setenv("OPENCODE_BRIDGE_TIMEOUT", "300")
config = resolve_config({})
assert config.request_timeout_seconds == 300