Skip to content

Commit

Permalink
nfpm: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Aug 15, 2024
1 parent 2bc5db6 commit a3eb4d2
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 22 deletions.
59 changes: 53 additions & 6 deletions src/python/pants/backend/nfpm/util_rules/generate_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,62 @@ def get_digest(rule_runner: RuleRunner, source_files: dict[str, str]) -> Digest:
(
# no dependencies
pytest.param("apk", NfpmApkPackageFieldSet, [], {}, [], {}, None, id="apk-no-deps"),
pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, [], {}, None, id="archlinux-no-deps"),
pytest.param(
"archlinux", NfpmArchlinuxPackageFieldSet, [], {}, [], {}, None, id="archlinux-no-deps"
),
pytest.param("deb", NfpmDebPackageFieldSet, [], {}, [], {}, None, id="deb-no-deps"),
pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, [], {}, None, id="rpm-no-deps"),
pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, [], {"ghost_contents": ["/var/log/pkg.log"]}, None, id="rpm-no-deps-with-ghost"),
pytest.param(
"rpm",
NfpmRpmPackageFieldSet,
[],
{},
[],
{"ghost_contents": ["/var/log/pkg.log"]},
None,
id="rpm-no-deps-with-ghost",
),
# no dependencies (extra file does not cause errors)
pytest.param("apk", NfpmApkPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="apk-no-deps-with-extra-file"),
pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="archlinux-no-deps-with-extra-file"),
pytest.param("deb", NfpmDebPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="deb-no-deps-with-extra-file"),
pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, ["contents/extra-file.txt"], {}, None, id="rpm-no-deps-with-extra-file"),
pytest.param(
"apk",
NfpmApkPackageFieldSet,
[],
{},
["contents/extra-file.txt"],
{},
None,
id="apk-no-deps-with-extra-file",
),
pytest.param(
"archlinux",
NfpmArchlinuxPackageFieldSet,
[],
{},
["contents/extra-file.txt"],
{},
None,
id="archlinux-no-deps-with-extra-file",
),
pytest.param(
"deb",
NfpmDebPackageFieldSet,
[],
{},
["contents/extra-file.txt"],
{},
None,
id="deb-no-deps-with-extra-file",
),
pytest.param(
"rpm",
NfpmRpmPackageFieldSet,
[],
{},
["contents/extra-file.txt"],
{},
None,
id="rpm-no-deps-with-extra-file",
),
pytest.param(
"rpm",
NfpmRpmPackageFieldSet,
Expand Down
82 changes: 66 additions & 16 deletions src/python/pants/backend/nfpm/util_rules/sandbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
@pytest.mark.parametrize(
"tgt,field_set_type,expected",
(
pytest.param(NfpmContentDir({"dst": "/foo"}, _A), NfpmPackageFieldSet, _DepCategory.ignore, id="content_dir"),
pytest.param(
NfpmContentDir({"dst": "/foo"}, _A),
NfpmPackageFieldSet,
_DepCategory.ignore,
id="content_dir",
),
pytest.param(
NfpmContentSymlink({"dst": "/foo", "src": "/bar"}, _A),
NfpmPackageFieldSet, # does not matter
Expand All @@ -91,26 +96,69 @@
_DepCategory.nfpm_content_from_source,
id="content_file-from-source",
),
pytest.param(_APK_PKG, NfpmApkPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-apk-apk"),
pytest.param(_APK_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-archlinux"),
pytest.param(
_APK_PKG, NfpmApkPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-apk-apk"
),
pytest.param(
_APK_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-archlinux"
),
pytest.param(_APK_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-deb"),
pytest.param(_APK_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-apk-rpm"),
pytest.param(_ARCHLINUX_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-apk"),
pytest.param(_ARCHLINUX_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-archlinux-archlinux"),
pytest.param(_ARCHLINUX_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-deb"),
pytest.param(_ARCHLINUX_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-rpm"),
pytest.param(
_ARCHLINUX_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-apk"
),
pytest.param(
_ARCHLINUX_PKG,
NfpmArchlinuxPackageFieldSet,
_DepCategory.nfpm_package,
id="pkgs-archlinux-archlinux",
),
pytest.param(
_ARCHLINUX_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-deb"
),
pytest.param(
_ARCHLINUX_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-archlinux-rpm"
),
pytest.param(_DEB_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-apk"),
pytest.param(_DEB_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-archlinux"),
pytest.param(_DEB_PKG, NfpmDebPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-deb-deb"),
pytest.param(
_DEB_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-archlinux"
),
pytest.param(
_DEB_PKG, NfpmDebPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-deb-deb"
),
pytest.param(_DEB_PKG, NfpmRpmPackageFieldSet, _DepCategory.ignore, id="pkgs-deb-rpm"),
pytest.param(_RPM_PKG, NfpmApkPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-apk"),
pytest.param(_RPM_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-archlinux"),
pytest.param(
_RPM_PKG, NfpmArchlinuxPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-archlinux"
),
pytest.param(_RPM_PKG, NfpmDebPackageFieldSet, _DepCategory.ignore, id="pkgs-rpm-deb"),
pytest.param(_RPM_PKG, NfpmRpmPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-rpm-rpm"),
pytest.param(GenericTarget({}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="generic_target"),
pytest.param(FileTarget({"source": "foo"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="file"),
pytest.param(ResourceTarget({"source": "foo"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="resource"),
pytest.param(ArchiveTarget({"format": "zip"}, _A), NfpmPackageFieldSet, _DepCategory.remaining, id="archive"),
pytest.param(
_RPM_PKG, NfpmRpmPackageFieldSet, _DepCategory.nfpm_package, id="pkgs-rpm-rpm"
),
pytest.param(
GenericTarget({}, _A),
NfpmPackageFieldSet,
_DepCategory.remaining,
id="generic_target",
),
pytest.param(
FileTarget({"source": "foo"}, _A),
NfpmPackageFieldSet,
_DepCategory.remaining,
id="file",
),
pytest.param(
ResourceTarget({"source": "foo"}, _A),
NfpmPackageFieldSet,
_DepCategory.remaining,
id="resource",
),
pytest.param(
ArchiveTarget({"format": "zip"}, _A),
NfpmPackageFieldSet,
_DepCategory.remaining,
id="archive",
),
),
)
def test_dep_category_for_target(
Expand Down Expand Up @@ -182,7 +230,9 @@ def rule_runner() -> RuleRunner:
(
# empty digest
pytest.param("apk", NfpmApkPackageFieldSet, [], {}, set(), id="apk-empty-digest"),
pytest.param("archlinux", NfpmArchlinuxPackageFieldSet, [], {}, set(), id="archlinux-empty-digest"),
pytest.param(
"archlinux", NfpmArchlinuxPackageFieldSet, [], {}, set(), id="archlinux-empty-digest"
),
pytest.param("deb", NfpmDebPackageFieldSet, [], {}, set(), id="deb-empty-digest"),
pytest.param("rpm", NfpmRpmPackageFieldSet, [], {}, set(), id="rpm-empty-digest"),
# non-empty digest
Expand Down

0 comments on commit a3eb4d2

Please sign in to comment.