Add more tests for gitrpm.py

Make sure that dotfiles are installed when not directly under /
Make sure / is not packaged in the rpm (it will cause a conflict with
the filesystem package).
Make sure that using destination="/" works
This commit is contained in:
Brian C. Lane 2019-03-29 14:05:09 -07:00
parent 049f68cb60
commit 6fd06c6931
2 changed files with 27 additions and 1 deletions

View File

@ -94,9 +94,13 @@ def create_git_repo():
for f in ["packages-only.toml", "groups-only.toml"]:
shutil.copy2(os.path.join(oldcwd, results_path, f), os.path.join(repodir, "only-bps/"))
test_results["second"].append(os.path.join("only-bps/", f))
# Add a dotfile as well
open(os.path.join(repodir, "only-bps/.bpsrc"), "w").write("dotfile test\n")
test_results["second"].append("only-bps/.bpsrc")
test_results["second"] = sorted(test_results["second"])
cmd = ["git", "add", "*.toml"]
cmd = ["git", "add", "*.toml", "only-bps/.bpsrc"]
subprocess.check_call(cmd)
cmd = ["git", "commit", "-m", "second files"]
subprocess.check_call(cmd)

View File

@ -157,6 +157,9 @@ class GitRpmTest(unittest.TestCase):
files = sorted(f.name for f in rpm.files(hdr) if stat.S_ISREG(f.mode))
self.assertEqual(files, [os.path.join(repo["destination"], f) for f in self.test_results[test_name]])
# / should never be included in the rpm, doing so conflicts with the filesystem package
self.assertFalse(any(True for f in files if f == "/"))
def git_branch_test(self):
"""Test creating an rpm from a git branch"""
git_repo = toml.loads("""
@ -246,6 +249,25 @@ class GitRpmTest(unittest.TestCase):
finally:
shutil.rmtree(temp_dir)
def git_root_test(self):
"""Test creating an rpm with / as the destination """
git_repo = toml.loads("""
[[repos.git]]
rpmname="git-rpm-test"
rpmversion="1.0.0"
rpmrelease="1"
summary="Testing the git rpm code"
repo="file://%s"
ref="v1.1.0"
destination="/"
""" % (self.repodir))
try:
rpm_dir = tempfile.mkdtemp(prefix="git-rpm-test.")
rpm_file = make_git_rpm(git_repo["repos"]["git"][0], rpm_dir)
self._check_rpm(git_repo["repos"]["git"][0], rpm_dir, rpm_file, "second")
finally:
shutil.rmtree(rpm_dir)
class GitRpmBuildTest(unittest.TestCase):
def get_base_dir_test(self):