Skip to content

Commit cac822f

Browse files
author
Zhe Yu
committed
tests(cli): Refactor query subcommand and add tests
1 parent bc49f85 commit cac822f

2 files changed

Lines changed: 75 additions & 535 deletions

File tree

src/vectorcode/subcommands/query/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _prepare_formatted_result(
3030
logger.warning(f"Skipping non-existent file: {res}")
3131
else:
3232
assert isinstance(res, Chunk)
33-
if res.start is None or res.end is None:
33+
if res.start is None or res.end is None: # pragma: nocover
3434
logger.warning(
3535
"This chunk doesn't have line range metadata. Please try re-vectorising the project."
3636
)
@@ -73,14 +73,20 @@ def preprocess_query_keywords(configs: Config):
7373
def verify_include(configs: Config):
7474
if QueryInclude.path not in configs.include:
7575
configs.include.append(QueryInclude.path)
76-
assert not (
76+
if (
7777
QueryInclude.chunk in configs.include
7878
and QueryInclude.document in configs.include
79-
), "`chunk` and `document` cannot be used at the same time for `--include`."
79+
):
80+
logger.error(
81+
"`chunk` and `document` cannot be used at the same time for `--include`."
82+
)
83+
return False
84+
return True
8085

8186

8287
async def query(configs: Config) -> int:
83-
verify_include(configs)
88+
if not verify_include(configs):
89+
return 1
8490

8591
assert configs.query
8692
preprocess_query_keywords(configs)

0 commit comments

Comments
 (0)