@@ -167,6 +167,35 @@ def test_returns_cwd_result_when_no_branch(
167167 assert result is worktree
168168
169169
170+ class TestCreateNew :
171+ @pytest .fixture
172+ def mock_git (self , mocker : MockerFixture ) -> MagicMock :
173+ mocker .patch ("git_workspace.worktree.git.pull_branch" )
174+ mocker .patch ("git_workspace.worktree.git.create_worktree_new" )
175+ return mocker .MagicMock ()
176+
177+ def test_pulls_base_branch_before_creating_worktree (
178+ self , mocker : MockerFixture , workspace : MagicMock , mock_git : MagicMock
179+ ) -> None :
180+ mock_pull = mocker .patch ("git_workspace.worktree.git.pull_branch" )
181+ mocker .patch ("git_workspace.worktree.git.create_worktree_new" )
182+
183+ Worktree ._create_new (workspace , BRANCH , BASE_BRANCH )
184+
185+ mock_pull .assert_called_once_with (BASE_BRANCH , cwd = workspace .dir )
186+
187+ def test_uses_manifest_base_branch_when_none_provided (
188+ self , mocker : MockerFixture , workspace : MagicMock , mock_git : MagicMock
189+ ) -> None :
190+ mock_pull = mocker .patch ("git_workspace.worktree.git.pull_branch" )
191+ mocker .patch ("git_workspace.worktree.git.create_worktree_new" )
192+ workspace .manifest .base_branch = BASE_BRANCH
193+
194+ Worktree ._create_new (workspace , BRANCH , None )
195+
196+ mock_pull .assert_called_once_with (BASE_BRANCH , cwd = workspace .dir )
197+
198+
170199class TestDelete :
171200 @pytest .fixture
172201 def mock_git_remove_worktree (self , mocker : MockerFixture ) -> MagicMock :
0 commit comments