2007-11-10 23:40:58 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_description='Verify snapshot'
|
2007-11-10 23:40:58 +00:00
|
|
|
. ./setup.sh
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'get foo/snapshot/master.tar.gz' '
|
|
|
|
cgit_url "foo/snapshot/master.tar.gz" >tmp
|
2007-11-10 23:40:58 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'check html headers' '
|
|
|
|
head -n 1 tmp |
|
2013-03-04 21:58:50 +00:00
|
|
|
grep "Content-Type: application/x-gzip" &&
|
2007-11-10 23:40:58 +00:00
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
head -n 2 tmp |
|
2013-03-04 21:58:50 +00:00
|
|
|
grep "Content-Disposition: inline; filename=.master.tar.gz."
|
2007-11-10 23:40:58 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'strip off the header lines' '
|
|
|
|
tail -n +6 tmp > master.tar.gz
|
2013-03-04 21:58:50 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'verify gzip format' '
|
|
|
|
gunzip --test master.tar.gz
|
2007-11-10 23:40:58 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'untar' '
|
|
|
|
rm -rf master &&
|
2013-04-08 22:13:52 +00:00
|
|
|
tar -xzf master.tar.gz
|
2008-10-05 11:13:03 +00:00
|
|
|
'
|
2007-11-10 23:40:58 +00:00
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'count files' '
|
|
|
|
ls master/ >output &&
|
|
|
|
test_line_count = 5 output
|
2007-11-10 23:40:58 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'verify untarred file-5' '
|
|
|
|
grep "^5$" master/file-5 &&
|
|
|
|
test_line_count = 1 master/file-5
|
2007-11-10 23:40:58 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'get foo/snapshot/master.zip' '
|
|
|
|
cgit_url "foo/snapshot/master.zip" >tmp
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'check HTML headers (zip)' '
|
|
|
|
head -n 1 tmp |
|
2013-03-04 21:58:51 +00:00
|
|
|
grep "Content-Type: application/x-zip" &&
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
head -n 2 tmp |
|
2013-03-04 21:58:51 +00:00
|
|
|
grep "Content-Disposition: inline; filename=.master.zip."
|
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_expect_success 'strip off the header lines (zip)' '
|
|
|
|
tail -n +6 tmp >master.zip
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-09 18:02:33 +00:00
|
|
|
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' '
|
2013-04-01 14:09:05 +00:00
|
|
|
unzip -t master.zip
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-09 18:02:33 +00:00
|
|
|
test_expect_success UNZIP 'unzip' '
|
2013-04-01 14:09:05 +00:00
|
|
|
rm -rf master &&
|
|
|
|
unzip master.zip
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-09 18:02:33 +00:00
|
|
|
test_expect_success UNZIP 'count files (zip)' '
|
2013-04-01 14:09:05 +00:00
|
|
|
ls master/ >output &&
|
|
|
|
test_line_count = 5 output
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-09 18:02:33 +00:00
|
|
|
test_expect_success UNZIP 'verify unzipped file-5' '
|
2013-04-01 14:09:05 +00:00
|
|
|
grep "^5$" master/file-5 &&
|
|
|
|
test_line_count = 1 master/file-5
|
2013-03-04 21:58:51 +00:00
|
|
|
'
|
|
|
|
|
2013-04-01 14:09:05 +00:00
|
|
|
test_done
|