@@ -85,6 +85,42 @@ async def test_execute_command_query(mock_language_server, mock_config):
8585 mock_language_server .progress .end .assert_called ()
8686
8787
88+ @pytest .mark .asyncio
89+ async def test_execute_command_query_invalid_include (mock_language_server , mock_config ):
90+ with (
91+ patch (
92+ "vectorcode.lsp_main.parse_cli_args" , new_callable = AsyncMock
93+ ) as mock_parse_cli_args ,
94+ patch ("vectorcode.lsp_main.get_database_connector" ),
95+ patch (
96+ "vectorcode.lsp_main.get_reranked_results" , new_callable = AsyncMock
97+ ) as mock_get_reranked_results ,
98+ patch ("os.path.isfile" , return_value = True ),
99+ patch ("builtins.open" , MagicMock ()) as mock_open ,
100+ ):
101+ mock_parse_cli_args .return_value = mock_config
102+ mock_get_reranked_results .return_value = []
103+
104+ # Configure the MagicMock object to return a string when read() is called
105+ mock_file = MagicMock ()
106+ mock_file .__enter__ .return_value .read .return_value = "{}" # Return valid JSON
107+ mock_open .return_value = mock_file
108+
109+ # Ensure parsed_args.project_root is not None
110+ mock_config .project_root = "/test/project"
111+ mock_config .query = ["test" ]
112+ mock_config .include = [QueryInclude .chunk , QueryInclude .document ]
113+
114+ # Mock the merge_from method
115+ mock_config .merge_from = AsyncMock (return_value = mock_config )
116+
117+ result = await execute_command (mock_language_server , ["query" , "test" ])
118+
119+ assert result == []
120+ mock_language_server .progress .begin .assert_called ()
121+ mock_language_server .progress .end .assert_called ()
122+
123+
88124@pytest .mark .asyncio
89125async def test_execute_command_query_default_proj_root (
90126 mock_language_server , mock_config
0 commit comments