Skip to content

Commit 75454de

Browse files
committed
Add tests for revision warning logging
1 parent 64d499e commit 75454de

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/unit_tests/cli/test_scratch.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,42 @@ def test_existing_repo_not_changed_to_new_branch(mock_repo, directory_path: Path
190190
repo.create_head.assert_not_called()
191191

192192

193+
@patch("blueapi.cli.scratch.Repo")
194+
@patch("blueapi.cli.scratch.LOGGER")
195+
def test_existing_repo_state_checked(
196+
mock_logger: MagicMock, mock_repo: MagicMock, directory_path: Path
197+
):
198+
repo = mock_repo.return_value
199+
repo.head.commit.name_rev = "current"
200+
repo.refs = {"demo": Mock()}
201+
202+
ensure_repo("http://example.com/foo.git", directory_path, "demo")
203+
204+
mock_logger.warning.assert_called_once_with(
205+
"Repository %s not at target revision: %r instead of %r",
206+
directory_path.name,
207+
repo.head.commit.name_rev,
208+
"demo",
209+
)
210+
211+
212+
@patch("blueapi.cli.scratch.Repo")
213+
@patch("blueapi.cli.scratch.LOGGER")
214+
def test_existing_repo_unknown_revision(
215+
mock_logger: MagicMock, mock_repo: MagicMock, directory_path: Path
216+
):
217+
repo = mock_repo.return_value
218+
repo.head.commit.name_rev = "current"
219+
repo.refs = {}
220+
221+
ensure_repo("http://example.com/foo.git", directory_path, "demo")
222+
223+
mock_logger.warning.assert_called_once_with(
224+
"Target revision %r not found",
225+
"demo",
226+
)
227+
228+
193229
def test_setup_scratch_fails_on_nonexistant_root(
194230
nonexistant_path: Path,
195231
):

0 commit comments

Comments
 (0)