diff --git a/test/test_extractor.py b/test/test_extractor.py index 91d25d1993..d73e7c1c22 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -9,7 +9,13 @@ import unittest.mock from io import BytesIO from os import path -from test.utils import CURL_7_20_0_URL, TMUX_DEB, download_file +from test.utils import ( + CURL_7_20_0_URL, + GLIB_PKG_URL, + TAR_ZST_URL, + TMUX_DEB, + download_file, +) from typing import List from zipfile import ZipFile, ZipInfo @@ -145,6 +151,45 @@ async def test_extract_file_rpm_no_rpm2cipo(self, extension_list: List[str]): mock_aio_run_command.assert_not_called() +class TestExtractFileZst(TestExtractorBase): + """Tests for the zst file extractor""" + + def setup_method(self): + download_file(TAR_ZST_URL, path.join(self.tempdir, "test.zst")) + + @pytest.fixture + def extension_list(self) -> List[str]: + return self.extractor.file_extractors[self.extractor.extract_file_zst] + + @pytest.mark.asyncio + async def test_extract_file_zst(self, extension_list: List[str]): + """Test the zst file extraction""" + async for extracted_path in self.extract_files( + [f"test{extension}" for extension in extension_list] + ): + assert path.isfile(path.join(extracted_path, "usr", "bin", "tar")) + + +class TestExtractFilePkg(TestExtractorBase): + """Tests for pkg file extractor""" + + def setup_method(self): + assert inpath("tar") or inpath("7z"), "Required tools 'tar' or '7z' not found" + download_file(GLIB_PKG_URL, path.join(self.tempdir, "test.pkg")) + + @pytest.fixture + def extension_list(self) -> List[str]: + return self.extractor.file_extractors[self.extractor.extract_file_pkg] + + @pytest.mark.asyncio + async def test_extract_file_pkg(self, extension_list: List[str]): + """Test the pkg file extraction""" + async for extracted_path in self.extract_files( + [f"test{extension}" for extension in extension_list] + ): + assert path.isfile(path.join(extracted_path, "usr", "local", "bin", "gio")) + + class TestExtractFileRpmWithZstd(TestExtractorBase): """Tests for the rpm file extractor (zstd/windows)""" diff --git a/test/utils.py b/test/utils.py index 42938ef402..f705ca4966 100644 --- a/test/utils.py +++ b/test/utils.py @@ -20,6 +20,12 @@ ) TMUX_DEB_NAME = "tmux_1.8-5_amd64.deb" TMUX_DEB = "https://mirrors.cat.pdx.edu/ubuntu/pool/main/t/tmux/" + TMUX_DEB_NAME +TAR_ZST_NAME = "tar-1.34-1-x86_64.pkg.tar.zst" +TAR_ZST_URL = "https://ftp5.gwdg.de/pub/linux/archlinux/core/os/x86_64/" + TAR_ZST_NAME +GLIB_PKG_NAME = "glib-2.70.4_3,2.pkg" +GLIB_PKG_URL = ( + "https://pkg.freebsd.org/FreeBSD:12:aarch64/quarterly/All/" + GLIB_PKG_NAME +) class TempDirTest: