test: 补充测试覆盖率 — DB/CLI/Search/Ingest + 修复 chromadb 异常兼容
This commit is contained in:
@@ -122,3 +122,25 @@ class TestSearcher:
|
||||
searcher = Searcher(db, embedder, "empty_coll")
|
||||
sources = searcher.list_sources()
|
||||
assert sources == []
|
||||
|
||||
|
||||
def test_list_sources_empty():
|
||||
"""空 collection 的 list_sources 返回空列表."""
|
||||
from src.core.search import Searcher
|
||||
|
||||
class EmptyColl:
|
||||
def count(self): return 0
|
||||
def get(self, **kwargs):
|
||||
return {"ids": [], "documents": [], "metadatas": []}
|
||||
|
||||
class EmptyDB:
|
||||
def get_or_create_collection(self, name): return EmptyColl()
|
||||
def list_collections(self): return []
|
||||
|
||||
class FakeEmb:
|
||||
@property
|
||||
def dimension(self): return 4
|
||||
def embed(self, texts): return [[0.0] * 4]
|
||||
|
||||
s = Searcher(EmptyDB(), FakeEmb(), "empty")
|
||||
assert s.list_sources() == []
|
||||
|
||||
Reference in New Issue
Block a user