summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-02-12 15:11:30 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-02-12 17:41:31 +0200
commit7cb44c43bd27b800686508f79e3b7b6a3ec39c45 (patch)
treee170e6e3fe3a5d2457216103debe49bd42154e91 /tests
parent1cc54e35d192ea39160ef0e3b22bf403cac2a141 (diff)
downloadgit-buildpackage-7cb44c43bd27b800686508f79e3b7b6a3ec39c45.tar.gz
git-buildpackage-7cb44c43bd27b800686508f79e3b7b6a3ec39c45.tar.bz2
git-buildpackage-7cb44c43bd27b800686508f79e3b7b6a3ec39c45.zip
import-orig-rpm: implement --create-missing-branches option
Create the upstream branch if it does not exist. Use the same option name that import-srpm has. Change-Id: I2e55a2d88348776e9f2d9110a33e36a79b26ffff Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/component/rpm/test_import_orig_rpm.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/component/rpm/test_import_orig_rpm.py b/tests/component/rpm/test_import_orig_rpm.py
index 7944cc57..e53d00c2 100644
--- a/tests/component/rpm/test_import_orig_rpm.py
+++ b/tests/component/rpm/test_import_orig_rpm.py
@@ -102,6 +102,15 @@ class ImportOrigTestBase(ComponentTestBase):
class TestImportOrig(ImportOrigTestBase):
"""Basic tests for git-import-orig-rpm"""
+ @staticmethod
+ def _init_repo_with_dummy_packaging():
+ """Create a dummy packaging branch with one commit"""
+ repo = GitRepository.create('.')
+ shutil.copy2('.git/HEAD', 'foobar')
+ repo.add_files('.')
+ repo.commit_all('First commit')
+ return repo
+
def test_invalid_args(self):
"""
See that import-orig-rpm fails gracefully when called with invalid args
@@ -188,10 +197,7 @@ class TestImportOrig(ImportOrigTestBase):
def test_import_to_existing(self):
"""Test importing of to an existing repo"""
# Create new repo and add dummy files
- repo = GitRepository.create('.')
- shutil.copy2('.git/HEAD', 'foobar')
- repo.add_files('.')
- repo.commit_all('First commit')
+ repo = self._init_repo_with_dummy_packaging()
sha1 = repo.rev_parse('HEAD^0')
# Test missing upstream branch
@@ -301,6 +307,21 @@ class TestImportOrig(ImportOrigTestBase):
eq_(mock_import(['--no-interactive', orig_renamed], stdin_data=''), 1)
self._check_log(-1, "gbp:error: Couldn't determine upstream version")
+ def test_option_create_missing(self):
+ """Test importing of to an existing repo"""
+ # Create new repo and add dummy files
+ repo = self._init_repo_with_dummy_packaging()
+
+ # Test missing upstream branch
+ orig = os.path.join(DATA_DIR, 'gbp-test2-2.0.tar.gz')
+ eq_(mock_import([orig]), 1)
+ self._check_log(1, 'Repository does not have branch')
+
+ # Try again, with --create-missing-branches
+ eq_(mock_import(['--create-missing-branches', orig]), 0)
+ self._check_repo_state(repo, 'master', ['master', 'upstream'])
+ eq_(len(repo.get_commits(until='upstream')), 1)
+
def test_misc_options(self):
"""Test various options of git-import-orig-rpm"""
repo = GitRepository.create('.')