summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-02-13 12:41:39 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-11-14 14:47:20 +0200
commit6dcdcdd1d37873e2feab6e108e744cb28fca0b12 (patch)
treef6d32d6b7cfe9f593b869f383a7e173c5e1aa348 /tests
parent0e8118863ca07fef874eed946455aefdc7737b17 (diff)
downloadgit-buildpackage-6dcdcdd1d37873e2feab6e108e744cb28fca0b12.tar.gz
git-buildpackage-6dcdcdd1d37873e2feab6e108e744cb28fca0b12.tar.bz2
git-buildpackage-6dcdcdd1d37873e2feab6e108e744cb28fca0b12.zip
import-orig-rpm: get archive from spec file
Try to get archive path/filename from spec file if no file name is given on the command line. This should make version bumps more straightforward: just update version number in the spec file and run 'git-import-orig-rpm'. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/component/rpm/test_import_orig_rpm.py47
1 files changed, 43 insertions, 4 deletions
diff --git a/tests/component/rpm/test_import_orig_rpm.py b/tests/component/rpm/test_import_orig_rpm.py
index 019dbdf8..a85366b1 100644
--- a/tests/component/rpm/test_import_orig_rpm.py
+++ b/tests/component/rpm/test_import_orig_rpm.py
@@ -39,6 +39,18 @@ from tests.component.rpm import RPM_TEST_DATA_DIR
DATA_DIR = os.path.join(RPM_TEST_DATA_DIR, 'orig')
+DUMMY_SPEC = """
+Name: dummy
+Version: 1.0
+Release: 0
+License: GPL-2.0
+Summary: Dummy package
+Source: %(source)s
+
+%%description
+Dummy package generated by unit tests
+"""
+
def mock_import(args, stdin_data="\n\n", cwd=None):
"""Wrapper for import-orig-rpm for feeding mock stdin data to it"""
old_cwd = os.path.abspath(os.path.curdir)
@@ -96,6 +108,13 @@ class TestImportOrig(ImportOrigTestBase):
repo.commit_all('First commit')
return repo
+ @staticmethod
+ def _create_dummy_spec(path, **kwargs):
+ """Create a dummy spec file"""
+ with open(path, 'w') as fobj:
+ print kwargs
+ fobj.write(DUMMY_SPEC % kwargs)
+
def test_invalid_args(self):
"""
See that import-orig-rpm fails gracefully when called with invalid args
@@ -103,10 +122,6 @@ class TestImportOrig(ImportOrigTestBase):
repo = GitRepository.create('.')
origs = [os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2'),
os.path.join(DATA_DIR, 'gbp-test-1.1.tar.bz2')]
- # Test empty args
- eq_(mock_import([]), 1)
- self._clear_log()
-
# Test multiple archives
eq_(mock_import([] + origs), 1)
self._check_log(0, 'gbp:error: More than one archive specified')
@@ -368,6 +383,30 @@ class TestImportOrig(ImportOrigTestBase):
# Other parts of the import should've succeeded
self._check_repo_state(repo, 'master', ['master', 'upstream'])
+ def test_archive_from_spec(self):
+ """Test taking archive file path from spec file"""
+ repo = GitRepository.create('.')
+ orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
+
+ # Test non-existent spec file
+ eq_(mock_import([]), 1)
+ self._check_log(0, '.*No archive to import specified and no spec file')
+
+ # Test non-existent archive
+ self._create_dummy_spec('dummy.spec', source='non-existent.tar.gz')
+ eq_(mock_import([]), 1)
+ self._check_log(-1, '.*unable to find \S+non-existent.tar.gz')
+
+ # Test failing download
+ self._create_dummy_spec('dummy.spec', source='foo://bar.tar.gz')
+ eq_(mock_import([]), 1)
+ self._check_log(-1, '.*Download failed')
+
+ # Test existing archive
+ self._create_dummy_spec('dummy.spec', source=orig)
+ eq_(mock_import([]), 0)
+ self._check_repo_state(repo, None, ['upstream'], ['dummy.spec'])
+
class TestPristineTar(ImportOrigTestBase):
"""