Skip to content

Commit

Permalink
add test for unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Mar 25, 2024
1 parent f9ed6cc commit 2656a8e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Binary file added test/asset/test.epub
Binary file not shown.
42 changes: 42 additions & 0 deletions test/test_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,48 @@ test_zip_read_file () {
"should fail if zippath does not exist"
}

test_zip_read_file () {
filepath_container="META-INF/container.xml"
zippath_testepub="./asset/test.epub"

# <container
# version="1.0"
# xmlns="urn:oasis:names:tc:opendocument:xmlns:container" >
# <rootfiles>
# <rootfile
# full-path="OEBPS/content.opf"
# media-type="application/oebps-package+xml" />
# </rootfiles>
# </container>
container=$(zip_read_file "$zippath_testepub" "$filepath_container")
containerurn="urn:oasis:names:tc:opendocument:xmlns:container"

assert_matches "$containerurl" "$container"
}

test_zip_move_file_out () {
filepath_container="META-INF/container.xml"
zippath_testepub="./asset/test.epub"
filepath_containeroutdir="./asset-out/"
filepath_containerout="${filepath_containeroutdir}container.xml"

# <container
# version="1.0"
# xmlns="urn:oasis:names:tc:opendocument:xmlns:container" >
# <rootfiles>
# <rootfile
# full-path="OEBPS/content.opf"
# media-type="application/oebps-package+xml" />
# </rootfiles>
# </container>
$(zip_move_file_out \
"$zippath_testepub" \
"$filepath_container" \
"$filepath_containeroutdir")

assert_matches "$containerurl" $(cat "$filepath_containerout")
}

setup_suite() {
source ../thu.sh
}

0 comments on commit 2656a8e

Please sign in to comment.