develop: 补齐 integrations 后端适配器单元测试

This commit is contained in:
Pipeline Agent 2026-08-15 11:30:15 +08:00
parent a7730f6dad
commit a06bc13a0e

View File

@ -17,8 +17,6 @@ from fault_log_analyzer.integrations import (
class TestElasticsearchSinkIndexName(unittest.TestCase):
"""ElasticsearchSink 的索引命名逻辑(不依赖 ES 客户端即可测试)。"""
def test_index_name_monthly_rollover(self):
sink = object.__new__(ElasticsearchSink)
sink._index_pattern = "hms-fault-log-{yyyy.MM}"
@ -41,9 +39,6 @@ class TestElasticsearchSinkIndexName(unittest.TestCase):
class TestLazyImportBackends(unittest.TestCase):
"""可选后端依赖kafka/elasticsearch/pymysql/redis未安装时实例化应抛出
明确的 RuntimeError而非影响核心逻辑与单元测试"""
def _assert_missing_dependency_raises_runtime_error(self, factory):
with patch("builtins.__import__", side_effect=ImportError("no optional dependency")):
with self.assertRaises(RuntimeError):