feat(external-connector): 默认连接器提供者改为官方版本
将环境变量 CONNECTOR_PROVIDER 的默认值从 "fake" 改为 "official", 以便在没有明确指定提供者时使用官方的连接器实现。
This commit is contained in:
@ -17,7 +17,7 @@ from external_connector.state import SidecarStateStore
|
|||||||
def build_app():
|
def build_app():
|
||||||
home = Path(os.getenv("CONNECTOR_HOME", "/var/lib/external-connector"))
|
home = Path(os.getenv("CONNECTOR_HOME", "/var/lib/external-connector"))
|
||||||
store = SidecarStateStore(home / "state.json")
|
store = SidecarStateStore(home / "state.json")
|
||||||
provider_name = os.getenv("CONNECTOR_PROVIDER", "fake")
|
provider_name = os.getenv("CONNECTOR_PROVIDER", "official")
|
||||||
if provider_name == "official":
|
if provider_name == "official":
|
||||||
provider = CompositeProvider([
|
provider = CompositeProvider([
|
||||||
_weixin_provider(store),
|
_weixin_provider(store),
|
||||||
|
|||||||
24
external-connector/tests/test_main.py
Normal file
24
external-connector/tests/test_main.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from external_connector import main
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_app_defaults_to_official_provider(monkeypatch, tmp_path) -> None:
|
||||||
|
monkeypatch.delenv("CONNECTOR_PROVIDER", raising=False)
|
||||||
|
monkeypatch.setenv("CONNECTOR_HOME", str(tmp_path))
|
||||||
|
|
||||||
|
app = main.build_app()
|
||||||
|
health = next(route.endpoint for route in app.routes if route.path == "/health")()
|
||||||
|
|
||||||
|
assert health["providerId"] == "composite"
|
||||||
|
assert [provider["providerId"] for provider in health["providers"]] == ["weixin_ilink", "feishu_bot"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_app_allows_explicit_fake_provider(monkeypatch, tmp_path) -> None:
|
||||||
|
monkeypatch.setenv("CONNECTOR_PROVIDER", "fake")
|
||||||
|
monkeypatch.setenv("CONNECTOR_HOME", str(tmp_path))
|
||||||
|
|
||||||
|
app = main.build_app()
|
||||||
|
health = next(route.endpoint for route in app.routes if route.path == "/health")()
|
||||||
|
|
||||||
|
assert health["providerId"] == "fake"
|
||||||
Reference in New Issue
Block a user