From e59cbdcd027353678a0a50b2ea3cbaaedefd86e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20M=2E=20Navarro?= Date: Fri, 20 Oct 2023 23:20:08 +0200 Subject: [PATCH] #9 added another test for the case when the local branch and the requested branch are different. --- src/tests/test_gitrepo.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/tests/test_gitrepo.py b/src/tests/test_gitrepo.py index 91a2fd0..4d9813e 100644 --- a/src/tests/test_gitrepo.py +++ b/src/tests/test_gitrepo.py @@ -57,7 +57,7 @@ def test_nonexitent_branch(self): self.assertEqual(result['status'], 'ERROR') - def test_local_not_in_remote(self): + def test_local_not_in_remote_same_branch(self): print("TEST: 'test_local_not_in_remote'") # prepares a suitable configuration repoconf = {} @@ -79,6 +79,27 @@ def test_local_not_in_remote(self): self.assertEqual(result['status'], 'WRONG_REMOTE') + def test_local_not_in_remote_different_branch(self): + print("TEST: 'test_local_not_in_remote'") + # prepares a suitable configuration + repoconf = {} + repoconf['repo'] = 'git@github.com:jmnavarrol/simplest-git-subrepos.git' + repoconf['path'] = os.path.join(self.scenarios_path, 'standard/simplest-git-subrepos') + + # First, let's clone the repo + result = self.gitrepo.update(repoconf) + print(str(result)) + # Then, let's create a local branch + repo = Repo(repoconf['path']) + new_branch = repo.create_head('new_branch') + # Finally, let's update config to request the new local branch + repoconf['branch'] = 'new_branch' + repoconf['gitref_type'] = 'branch' + result = self.gitrepo.update(repoconf) + print(str(result)) + self.assertEqual(result['status'], 'WRONG_REMOTE') + + def test_status_not_cloned(self): print("TEST: 'test_status_not_cloned'") # prepares a suitable configuration