Skip to content

Commit

Permalink
nfpm: fix util_rule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Jan 2, 2025
1 parent 755cde1 commit 381ceb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions src/python/pants/backend/nfpm/util_rules/generate_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
NfpmApkPackageFieldSet,
["contents:dummy_package"],
{},
["output_path/package"],
["dummy", "output_path/package"],
{},
None,
id="apk-with-pkg-dep",
Expand All @@ -277,7 +277,7 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
NfpmArchlinuxPackageFieldSet,
["contents:dummy_package"],
{},
["output_path/package"],
["dummy", "output_path/package"],
{},
None,
id="archlinux-with-pkg-dep",
Expand All @@ -287,7 +287,7 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
NfpmDebPackageFieldSet,
["contents:dummy_package"],
{},
["output_path/package"],
["dummy", "output_path/package"],
{},
None,
id="deb-with-pkg-dep",
Expand All @@ -297,7 +297,7 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
NfpmRpmPackageFieldSet,
["contents:dummy_package"],
{},
["output_path/package"],
["dummy", "output_path/package"],
{},
None,
id="rpm-with-pkg-dep",
Expand All @@ -307,7 +307,7 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
NfpmRpmPackageFieldSet,
["contents:dummy_package"],
{},
["output_path/package"],
["dummy", "output_path/package"],
{"ghost_contents": ["/var/log/pkg.log"]},
None,
id="rpm-with-pkg-dep-and-ghost",
Expand Down Expand Up @@ -528,8 +528,9 @@ def test_generate_nfpm_yaml(
dst="/etc/{_PKG_NAME}",
file_mode=0o700,
)
target(
file(
name="dummy",
source="dummy",
# For this test, the dummy target should be
# treated as if it were a package that defines:
# output_path="output_path/package"
Expand All @@ -542,7 +543,7 @@ def test_generate_nfpm_yaml(
dependencies=[":dummy"],
# NOTE: src pointing to package dep is relative to
# the build_root instead of this BUILD file.
src="ouptut_path/package",
src="output_path/package",
dst="/usr/bin/dummy_package",
file_mode=0o550,
)
Expand Down Expand Up @@ -699,6 +700,14 @@ def test_generate_nfpm_yaml(
entry = contents_by_dst.pop(dst)
assert "ghost" == entry["type"]

if "contents:dummy_package" in dependencies:
assert "dummy" not in contents_by_dst
dst = "/usr/bin/dummy_package"
assert dst in contents_by_dst
entry = contents_by_dst.pop(dst)
assert "" == entry["type"]
assert 0o0550 == entry["file_info"]["mode"]

# make sure all contents have been accounted for (popped off above)
assert len(contents_by_dst) == 0

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/nfpm/util_rules/sandbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def test_populate_nfpm_content_sandbox(
name="output_path_package",
src="relative_to_build_root.tar",
dst="/opt/foo/relative_to_build_root.tar",
dependencies=[":archive"],
dependencies=[":output_path_archive"],
)
"""
),
Expand Down

0 comments on commit 381ceb8

Please sign in to comment.