From 4fa08eb8e1ddda5005246b9c359d00f1398e228e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 29 Mar 2019 14:05:09 -0700 Subject: [PATCH] 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 (cherry picked from commit 6fd06c6931ee6561489020a11bfcf3621d9d274e) (cherry picked from commit d5d60ebe6deed34686e0dba44a400c907a431ff9) --- tests/lib.py | 6 +++++- tests/pylorax/test_gitrpm.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/lib.py b/tests/lib.py index de625dbf..a57c866a 100644 --- a/tests/lib.py +++ b/tests/lib.py @@ -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) diff --git a/tests/pylorax/test_gitrpm.py b/tests/pylorax/test_gitrpm.py index 500a34ed..04411b1b 100644 --- a/tests/pylorax/test_gitrpm.py +++ b/tests/pylorax/test_gitrpm.py @@ -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):