diff options
author | 2022-10-22 15:35:20 +0300 | |
---|---|---|
committer | 2022-10-26 21:45:13 +0300 | |
commit | beb8b645c88c95bab512c04c1df811e7cf5b3250 (patch) | |
tree | dd1bff822ab50647d03da32857aaff88ccd27346 /tests | |
parent | tests: fix flaky network scan MetadataUrlCheck/RedirectedUrl (diff) | |
download | pkgcheck-beb8b645c88c95bab512c04c1df811e7cf5b3250.tar.gz pkgcheck-beb8b645c88c95bab512c04c1df811e7cf5b3250.tar.bz2 pkgcheck-beb8b645c88c95bab512c04c1df811e7cf5b3250.zip |
BetterCompressionCheck: detect better compression uris
Resolves: https://github.com/pkgcore/pkgcheck/issues/479
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/checks/test_codingstyle.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/checks/test_codingstyle.py b/tests/checks/test_codingstyle.py index 0324b349..3becc919 100644 --- a/tests/checks/test_codingstyle.py +++ b/tests/checks/test_codingstyle.py @@ -315,6 +315,48 @@ class TestObsoleteUri(misc.ReportTestCase): assert uri in str(r) +class TestBetterCompression(misc.ReportTestCase): + + check_kls = codingstyle.BetterCompressionCheck + + def test_github_archive_uri(self): + uri = 'https://github.com/foo/bar/archive/${PV}.tar.gz' + fake_src = [ + f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n' + ] + fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src) + self.assertNoReport(self.check_kls(None), fake_pkg) + + def test_comment_uri(self): + uri = 'https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar' + fake_src = [ + f'#SRC_URI="{uri} -> ${{P}}.tar.gz"\n', + " ", + " ", + f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n', + ] + fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src) + r = self.assertReport(self.check_kls(None), fake_pkg) + assert r.lineno == 4 + + @pytest.mark.parametrize('uri', ( + 'https://gitlab.com/GNOME/${PN}/-/archive/${PV}/${P}.tar', + 'https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.tar.gz', + 'https://gitlab.gnome.org/GNOME/${PN}/-/archive/${PV}/${P}.zip', + 'https://gitlab.freedesktop.org/glvnd/${PN}/-/archive/v${PV}/${PN}-v${PV}.tar.gz', + )) + def test_gitlab_archive_uri(self, uri): + fake_src = [ + f'SRC_URI="{uri} -> ${{P}}.tar.gz"\n' + ] + fake_pkg = misc.FakePkg("dev-util/diffball-0.5", lines=fake_src) + r = self.assertReport(self.check_kls(None), fake_pkg) + assert r.lineno == 1 + assert r.line == uri + assert r.replacement == '.tar.bz2' + assert uri in str(r) + + class TestStaticSrcUri(misc.ReportTestCase): check_kls = codingstyle.MetadataVarCheck |