X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/c95cc5ec56dbb7394015eb18201403be6d80f69b..06671f4b2167951c6b46401b0f5ac8af4d48d50a:/tests/t0107-snapshot.sh diff --git a/tests/t0107-snapshot.sh b/tests/t0107-snapshot.sh index 4fbe45e..a845ad9 100755 --- a/tests/t0107-snapshot.sh +++ b/tests/t0107-snapshot.sh @@ -16,7 +16,7 @@ test_expect_success 'check html headers' ' ' test_expect_success 'strip off the header lines' ' - tail -n +6 tmp > master.tar.gz + strip_headers master.tar.gz ' test_expect_success 'verify gzip format' ' @@ -25,7 +25,7 @@ test_expect_success 'verify gzip format' ' test_expect_success 'untar' ' rm -rf master && - tar -xf master.tar.gz + tar -xzf master.tar.gz ' test_expect_success 'count files' ' @@ -38,6 +38,48 @@ test_expect_success 'verify untarred file-5' ' test_line_count = 1 master/file-5 ' +if test -n "$(which lzip 2>/dev/null)"; then + test_set_prereq LZIP +else + say 'Skipping LZIP validation tests: lzip not found' +fi + +test_expect_success LZIP 'get foo/snapshot/master.tar.lz' ' + cgit_url "foo/snapshot/master.tar.lz" >tmp +' + +test_expect_success LZIP 'check html headers' ' + head -n 1 tmp | + grep "Content-Type: application/x-lzip" && + + head -n 2 tmp | + grep "Content-Disposition: inline; filename=.master.tar.lz." +' + +test_expect_success LZIP 'strip off the header lines' ' + strip_headers master.tar.lz +' + +test_expect_success LZIP 'verify lzip format' ' + lzip --test master.tar.lz && + cp master.tar.lz /tmp/. +' + +test_expect_success LZIP 'untar' ' + rm -rf master && + tar --lzip -xf master.tar.lz +' + +test_expect_success LZIP 'count files' ' + ls master/ >output && + test_line_count = 5 output +' + +test_expect_success LZIP 'verify untarred file-5' ' + grep "^5$" master/file-5 && + test_line_count = 1 master/file-5 +' + test_expect_success 'get foo/snapshot/master.zip' ' cgit_url "foo/snapshot/master.zip" >tmp ' @@ -51,24 +93,30 @@ test_expect_success 'check HTML headers (zip)' ' ' test_expect_success 'strip off the header lines (zip)' ' - tail -n +6 tmp >master.zip + strip_headers master.zip ' -test_expect_success 'verify zip format' ' +if test -n "$(which unzip 2>/dev/null)"; then + test_set_prereq UNZIP +else + say 'Skipping ZIP validation tests: unzip not found' +fi + +test_expect_success UNZIP 'verify zip format' ' unzip -t master.zip ' -test_expect_success 'unzip' ' +test_expect_success UNZIP 'unzip' ' rm -rf master && unzip master.zip ' -test_expect_success 'count files (zip)' ' +test_expect_success UNZIP 'count files (zip)' ' ls master/ >output && test_line_count = 5 output ' -test_expect_success 'verify unzipped file-5' ' +test_expect_success UNZIP 'verify unzipped file-5' ' grep "^5$" master/file-5 && test_line_count = 1 master/file-5 '