generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
author
committed
Dec 12, 2024
1 parent
2d961e8
commit 11653a8
Showing
1 changed file
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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): | ||
|
@@ -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 | ||
) | ||
|
||
|
||
|
@@ -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 | ||
) |