Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-container (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
The old test tests/unit/pkgmgr/actions/test_branch.py has been removed because: - it targeted the previous monolithic pkgmgr.actions.branch module structure - its patch targets no longer match the refactored code - its responsibilities are now fully covered by the new, dedicated unit, integration, and E2E tests for branch actions and CLI wiring This avoids redundant coverage and prevents misleading or broken tests after the branch refactor. https://chatgpt.com/share/693bcc8d-b84c-800f-8510-8d6c66faf627
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
import unittest
|
|
from unittest.mock import patch, MagicMock
|
|
|
|
from pkgmgr.actions.branch.open_branch import open_branch
|
|
|
|
|
|
class TestOpenBranch(unittest.TestCase):
|
|
@patch("pkgmgr.actions.branch.open_branch._resolve_base_branch", return_value="main")
|
|
@patch("pkgmgr.actions.branch.open_branch.run_git")
|
|
def test_open_branch_executes_git_commands(self, run_git, resolve):
|
|
open_branch("feature-x", base_branch="main", cwd=".")
|
|
expected_calls = [
|
|
(["fetch", "origin"],),
|
|
(["checkout", "main"],),
|
|
(["pull", "origin", "main"],),
|
|
(["checkout", "-b", "feature-x"],),
|
|
(["push", "-u", "origin", "feature-x"],),
|
|
]
|
|
actual = [call.args for call in run_git.call_args_list]
|
|
self.assertEqual(actual, expected_calls)
|
|
|
|
@patch("builtins.input", return_value="auto-branch")
|
|
@patch("pkgmgr.actions.branch.open_branch._resolve_base_branch", return_value="main")
|
|
@patch("pkgmgr.actions.branch.open_branch.run_git")
|
|
def test_open_branch_prompts_for_name(self, run_git, resolve, input_mock):
|
|
open_branch(None)
|
|
calls = [call.args for call in run_git.call_args_list]
|
|
self.assertEqual(calls[3][0][0], "checkout") # verify git executed normally
|
|
|
|
def test_open_branch_rejects_empty_name(self):
|
|
with patch("builtins.input", return_value=""):
|
|
with self.assertRaises(RuntimeError):
|
|
open_branch(None)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|