Skip to content

Commit 8e4ade8

Browse files
committed
tests(cli): Add test for non-existing collection
1 parent 74bb7dd commit 8e4ade8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,18 @@ async def test_get_collection():
242242
mock_client.get_collection.assert_called_once()
243243
mock_client.get_or_create_collection.assert_not_called()
244244

245+
# Test retrieving a non-existing collection
246+
with patch("chromadb.AsyncHttpClient") as MockAsyncHttpClient:
247+
from vectorcode.common import __COLLECTION_CACHE
248+
249+
__COLLECTION_CACHE.clear()
250+
mock_client = MagicMock(spec=AsyncClientAPI)
251+
mock_client.get_collection.side_effect = ValueError
252+
MockAsyncHttpClient.return_value = mock_client
253+
254+
with pytest.raises(ValueError):
255+
collection = await get_collection(mock_client, config, False)
256+
245257
# Test creating a collection if it doesn't exist
246258
with patch("chromadb.AsyncHttpClient") as MockAsyncHttpClient:
247259
mock_client = MagicMock(spec=AsyncClientAPI)

0 commit comments

Comments
 (0)