@@ -174,6 +174,47 @@ async def test_checkout_branch_remoteref_success():
174174 assert {"code" : rc , "message" : stdout_message } == actual_response
175175
176176
177+ @pytest .mark .asyncio
178+ async def test_checkout_branch_remoteref_success_when_has_slash ():
179+ branch = "origin/test-branch/test"
180+ local_branch = "test-branch/test"
181+ curr_path = str (Path ("/bin/test_curr_path" ))
182+ stdout_message = "checkout output from git"
183+ stderr_message = ""
184+ rc = 0
185+
186+ with patch ("jupyterlab_git.git.execute" ) as mock_execute :
187+ with patch .object (
188+ Git ,
189+ "_get_branch_reference" ,
190+ return_value = maybe_future ("refs/remotes/remote_branch" ),
191+ ) as mock__get_branch_reference :
192+ # Given
193+ mock_execute .return_value = maybe_future (
194+ (rc , stdout_message , stderr_message )
195+ )
196+
197+ # When
198+ actual_response = await Git ().checkout_branch (
199+ branchname = branch , path = curr_path
200+ )
201+
202+ # Then
203+ mock__get_branch_reference .assert_has_calls ([call (branch , curr_path )])
204+
205+ cmd = ["git" , "checkout" , "-B" , local_branch , branch ]
206+ mock_execute .assert_called_once_with (
207+ cmd ,
208+ cwd = str (Path ("/bin" ) / "test_curr_path" ),
209+ timeout = 20 ,
210+ env = None ,
211+ username = None ,
212+ password = None ,
213+ is_binary = False ,
214+ )
215+
216+ assert {"code" : rc , "message" : stdout_message } == actual_response
217+
177218@pytest .mark .asyncio
178219async def test_checkout_branch_headsref_failure ():
179220 branch = "test-branch"
0 commit comments