11import logging
2+ from pathlib import Path
23from unittest import mock
34
45import click
@@ -73,7 +74,14 @@ def test_review_cli_github(*args: mock.MagicMock) -> None:
7374@mock .patch ("lgtm_ai.__main__.CodeReviewer" )
7475@mock .patch ("lgtm_ai.__main__.PrettyFormatter" )
7576@mock .patch ("lgtm_ai.__main__.get_git_client" )
76- def test_review_cli_local (* args : mock .MagicMock ) -> None :
77+ def test_review_cli_local (
78+ m_get_git_client : mock .MagicMock ,
79+ m_formatter : mock .MagicMock ,
80+ m_reviewer : mock .MagicMock ,
81+ tmp_path : Path ,
82+ ) -> None :
83+ # Create a .git directory to simulate a git repository
84+ (tmp_path / ".git" ).mkdir ()
7785 runner = CliRunner ()
7886 result = runner .invoke (
7987 review ,
@@ -90,14 +98,19 @@ def test_review_cli_local(*args: mock.MagicMock) -> None:
9098@mock .patch ("lgtm_ai.__main__.CodeReviewer" )
9199@mock .patch ("lgtm_ai.__main__.PrettyFormatter" )
92100@mock .patch ("lgtm_ai.__main__.get_git_client" )
93- def test_review_cli_local_does_not_exist (* args : mock .MagicMock ) -> None :
101+ def test_review_cli_local_does_not_exist (
102+ m_get_git_client : mock .MagicMock ,
103+ m_formatter : mock .MagicMock ,
104+ m_reviewer : mock .MagicMock ,
105+ tmp_path : Path ,
106+ ) -> None :
94107 runner = CliRunner ()
95108 result = runner .invoke (
96109 review ,
97110 [
98111 "--ai-api-key" ,
99112 "fake-token" ,
100- "./foo/bar/baz " ,
113+ "./fake " ,
101114 ],
102115 catch_exceptions = False ,
103116 )
@@ -162,8 +175,8 @@ def test_guide_cli_local_fails(*args: mock.MagicMock) -> None:
162175 catch_exceptions = False ,
163176 )
164177
165- assert result .exit_code == 1
166- assert "Aborted! " in result .stderr
178+ assert result .exit_code == 2
179+ assert "Invalid value for 'TARGET': The PR URL must be a valid URL " in result .stderr
167180
168181
169182@pytest .mark .parametrize (
0 commit comments