Skip to content

Commit

Permalink
commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
author committed Dec 12, 2024
1 parent 2d961e8 commit 11653a8
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions tests/plugins/github/handlers/test_git_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ async def test_checkout_branch(mocker: MockerFixture):
git_handler = GitHandler()
git_handler.checkout_branch("main")

mock_run_shell_command.assert_called_once_with(["git", "checkout", "main"])
mock_run_shell_command.assert_called_once_with(
["git", "checkout", "main"], check=True, capture_output=True
)


async def test_checkout_remote_branch(mocker: MockerFixture):
Expand All @@ -20,8 +22,12 @@ async def test_checkout_remote_branch(mocker: MockerFixture):
git_handler = GitHandler()
git_handler.checkout_remote_branch("main")

mock_run_shell_command.assert_any_call(["git", "fetch", "origin", "main"])
mock_run_shell_command.assert_any_call(["git", "checkout", "main"])
mock_run_shell_command.assert_any_call(
["git", "fetch", "origin", "main"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(
["git", "checkout", "main"], check=True, capture_output=True
)


async def test_commit_and_push(mocker: MockerFixture):
Expand All @@ -33,16 +39,30 @@ async def test_commit_and_push(mocker: MockerFixture):
git_handler.commit_and_push("commit message", "main", "author")

mock_run_shell_command.assert_any_call(
["git", "config", "--global", "user.name", "author"]
["git", "config", "--global", "user.name", "author"],
check=True,
capture_output=True,
)
mock_run_shell_command.assert_any_call(
["git", "config", "--global", "user.email", "[email protected]"],
check=True,
capture_output=True,
)
mock_run_shell_command.assert_any_call(
["git", "add", "-A"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(
["git", "commit", "-m", "commit message"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(
["git", "fetch", "origin"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(
["git", "config", "--global", "user.email", "[email protected]"]
["git", "diff", "origin/main", "main"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(
["git", "push", "origin", "main", "-f"], check=True, capture_output=True
)
mock_run_shell_command.assert_any_call(["git", "add", "-A"])
mock_run_shell_command.assert_any_call(["git", "commit", "-m", "commit message"])
mock_run_shell_command.assert_any_call(["git", "fetch", "origin"])
mock_run_shell_command.assert_any_call(["git", "diff", "origin/main", "main"])
mock_run_shell_command.assert_any_call(["git", "push", "origin", "main", "-f"])


async def test_delete_origin_branch(mocker: MockerFixture):
Expand All @@ -54,7 +74,7 @@ async def test_delete_origin_branch(mocker: MockerFixture):
git_handler.delete_origin_branch("main")

mock_run_shell_command.assert_called_once_with(
["git", "push", "origin", "--delete", "main"]
["git", "push", "origin", "--delete", "main"], check=True, capture_output=True
)


Expand All @@ -66,4 +86,6 @@ async def test_switch_branch(mocker: MockerFixture):
git_handler = GitHandler()
git_handler.switch_branch("main")

mock_run_shell_command.assert_called_once_with(["git", "switch", "-C", "main"])
mock_run_shell_command.assert_called_once_with(
["git", "switch", "-C", "main"], check=True, capture_output=True
)

0 comments on commit 11653a8

Please sign in to comment.