File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ def analyse(
7373 if outdir :
7474 codelinks_config .outdir = outdir
7575
76+ project_errors : list [str ] = []
77+ if projects :
78+ for project in projects :
79+ if project not in codelinks_config .projects :
80+ if not project_errors :
81+ project_errors .append ("The following projects are not found:" )
82+ project_errors .append (project )
83+ if project_errors :
84+ raise typer .BadParameter (f"{ linesep .join (project_errors )} " )
85+
7686 specifed_project_configs : dict [str , CodeLinksProjectConfigType ] = {}
7787 for project , _config in codelinks_config .projects .items ():
7888 if projects and project not in projects :
Original file line number Diff line number Diff line change @@ -179,3 +179,36 @@ def test_analyse_config_negative(
179179 assert result .exit_code != 0
180180 for line in output_lines :
181181 assert line in result .stdout
182+
183+
184+ @pytest .mark .parametrize (
185+ ("projects" , "output_lines" ),
186+ [
187+ (
188+ ["project_1" , "project_2" ],
189+ [
190+ "The following projects are not found:" ,
191+ "project_2" ,
192+ ],
193+ ),
194+ ],
195+ )
196+ def test_analyse_project_negative (projects , output_lines , tmp_path : Path ) -> None :
197+ config_file = tmp_path / "codelinks_config.toml"
198+ codelink_dict = {"codelinks" : CODELINKS_CONFIG_TEMPLATE }
199+ with config_file .open ("w" , encoding = "utf-8" ) as f :
200+ toml .dump (codelink_dict , f )
201+ projects_config = []
202+ for project in projects :
203+ projects_config .append ("--project" )
204+ projects_config .append (project )
205+
206+ options = [
207+ "analyse" ,
208+ str (config_file ),
209+ ]
210+ options .extend (projects_config )
211+ result = runner .invoke (app , options )
212+ assert result .exit_code != 0
213+ for line in output_lines :
214+ assert line in result .stdout
You can’t perform that action at this time.
0 commit comments