20 lines
457 B
Python
20 lines
457 B
Python
import pytest
|
|
|
|
from src.index import search
|
|
|
|
|
|
def test_search_returns_list():
|
|
results = search("test")
|
|
assert isinstance(results, list)
|
|
assert len(results) == 5 # default limit
|
|
|
|
|
|
def test_search_limit():
|
|
results = search("example", limit=3)
|
|
assert len(results) == 3
|
|
assert results == ["example result 1", "example result 2", "example result 3"]
|
|
|
|
|
|
def test_search_empty_query():
|
|
with pytest.raises(ValueError):
|
|
search("") |