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