Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
Signed-off-by: Appu Goundan <appu@google.com>
  • Loading branch information
loosebazooka authored and gravypod committed Aug 24, 2021
1 parent c5b3d52 commit 8e5198f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/container/build_tar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ def testPackageNameParserValidMetadata(self):
"""
self.assertEqual('test', TarFile.parse_pkg_name(metadata, "test.deb"))

def testPkgMetadataStatusFileName(self):
metadata = """Package: test
Description: Dummy
Version: 1.2.4
"""
with tempfile.TemporaryDirectory() as tmp:
# write control file into a metadata tar
control_file_name = path.join(tmp, "control")
with open(control_file_name, "w") as control_file:
control_file.write(metadata)
metadata_tar_file_name = path.join(tmp, "metadata.tar")
with tarfile.open(metadata_tar_file_name, "w") as metadata_tar_file:
metadata_tar_file.add(control_file_name, arcname="control")


output_file_name = path.join(tmp, "output.tar")
with TarFile(output_file_name, directory="/", compression=None, root_directory="./", default_mtime=None,
enable_mtime_preservation=False, xz_path="", force_posixpath=False) as output_file:
output_file.add_pkg_metadata(metadata_tar_file_name, "ignored.deb")

with tarfile.open(output_file_name) as output_file:
contained_names = output_file.getnames()

self.assertIn('./var/lib/dpkg/status.d/test', contained_names)


def testPackageNameParserInvalidMetadata(self):
metadata = "Package Name: Invalid"
self.assertEqual('test-invalid-pkg',
Expand Down

0 comments on commit 8e5198f

Please sign in to comment.