test: add StageTests.test_zip() to run zip inside a stage too
Similar to the tar test this adds a zip test that runs inside the stages.
This commit is contained in:
parent
91f47ddf03
commit
7279c44c53
3 changed files with 31 additions and 14 deletions
|
|
@ -898,7 +898,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "zip",
|
||||
"name": "tree",
|
||||
"build": "name:build",
|
||||
"stages": [
|
||||
{
|
||||
|
|
@ -915,13 +915,7 @@
|
|||
"options": {
|
||||
"filename": "zipfile.zip"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "zip-with-paths",
|
||||
"build": "name:build",
|
||||
"stages": [
|
||||
},
|
||||
{
|
||||
"type": "org.osbuild.zip",
|
||||
"inputs": {
|
||||
|
|
@ -934,7 +928,7 @@
|
|||
}
|
||||
},
|
||||
"options": {
|
||||
"filename": "zipfile.zip",
|
||||
"filename": "zipfile-w-includes.zip",
|
||||
"include": [
|
||||
"testfile"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pipelines:
|
|||
- from:
|
||||
mpp-format-string: input://inlinefile/{embedded['42']}
|
||||
to: tree:///testfile2
|
||||
- name: zip
|
||||
- name: tree
|
||||
build: name:build
|
||||
stages:
|
||||
- type: org.osbuild.zip
|
||||
|
|
@ -42,9 +42,7 @@ pipelines:
|
|||
- name:input-tree
|
||||
options:
|
||||
filename: zipfile.zip
|
||||
- name: zip-with-paths
|
||||
build: name:build
|
||||
stages:
|
||||
# one zip with inclues
|
||||
- type: org.osbuild.zip
|
||||
inputs:
|
||||
tree:
|
||||
|
|
@ -53,5 +51,5 @@ pipelines:
|
|||
references:
|
||||
- name:input-tree
|
||||
options:
|
||||
filename: zipfile.zip
|
||||
filename: zipfile-w-includes.zip
|
||||
include: ['testfile']
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import tarfile
|
|||
import tempfile
|
||||
import unittest
|
||||
import xml
|
||||
import zipfile
|
||||
from collections.abc import Mapping
|
||||
from typing import Callable, Dict, List, Optional
|
||||
|
||||
|
|
@ -369,6 +370,30 @@ class TestStages(test.TestBase):
|
|||
# cache the downloaded data for the files source
|
||||
osb.copy_source_data(self.store, "org.osbuild.files")
|
||||
|
||||
def test_zip(self):
|
||||
datadir = self.locate_test_data()
|
||||
testdir = os.path.join(datadir, "stages", "zip")
|
||||
|
||||
testcases = {
|
||||
"zipfile.zip": ["testfile", "testfile2"],
|
||||
"zipfile-w-includes.zip": ["testfile"]
|
||||
}
|
||||
with self.osbuild as osb, tempfile.TemporaryDirectory(dir="/var/tmp") as outdir:
|
||||
osb.compile_file(os.path.join(testdir, "zip.json"),
|
||||
exports=["tree"],
|
||||
output_dir=outdir)
|
||||
|
||||
for zip_filename, expected_content in testcases.items():
|
||||
tree = os.path.join(outdir, "tree")
|
||||
zp = os.path.join(tree, zip_filename)
|
||||
assert os.path.exists(zp), f"cannot find expected {zp}"
|
||||
with zipfile.ZipFile(zp) as zfp:
|
||||
names = zfp.namelist()
|
||||
assert sorted(expected_content) == sorted(names)
|
||||
|
||||
# cache the downloaded data for the files source
|
||||
osb.copy_source_data(self.store, "org.osbuild.files")
|
||||
|
||||
@unittest.skipUnless(have_sfdisk_with_json(), "Need sfdisk with JSON support")
|
||||
def _test_partitioning_stage(self, stage_name, sfdisk_out_filter_fn: Optional[Callable[[Dict], Dict]] = None):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue