Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 1 | #!/bin/sh |
2 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 3 | test_description='Verify snapshot' |
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 4 | . ./setup.sh |
5 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 6 | test_expect_success 'get foo/snapshot/master.tar.gz' ' |
7 | cgit_url "foo/snapshot/master.tar.gz" >tmp | ||||
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 8 | ' |
9 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 10 | test_expect_success 'check html headers' ' |
11 | head -n 1 tmp | | ||||
John Keeping | f9b801a | 2013-03-04 21:58:50 +0000 | [diff] [blame] | 12 | grep "Content-Type: application/x-gzip" && |
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 13 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 14 | head -n 2 tmp | |
John Keeping | f9b801a | 2013-03-04 21:58:50 +0000 | [diff] [blame] | 15 | grep "Content-Disposition: inline; filename=.master.tar.gz." |
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 16 | ' |
17 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 18 | test_expect_success 'strip off the header lines' ' |
John Keeping | 75bfec6 | 2013-05-18 18:46:38 +0100 | [diff] [blame] | 19 | strip_headers <tmp >master.tar.gz |
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 20 | ' |
21 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 22 | test_expect_success 'verify gzip format' ' |
23 | gunzip --test master.tar.gz | ||||
John Keeping | f9b801a | 2013-03-04 21:58:50 +0000 | [diff] [blame] | 24 | ' |
25 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 26 | test_expect_success 'untar' ' |
27 | rm -rf master && | ||||
Lukas Fleischer | 410da3a | 2013-04-09 00:13:52 +0200 | [diff] [blame] | 28 | tar -xzf master.tar.gz |
Lars Hjemli | 204669f | 2008-10-05 13:13:03 +0200 | [diff] [blame] | 29 | ' |
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 30 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 31 | test_expect_success 'count files' ' |
32 | ls master/ >output && | ||||
33 | test_line_count = 5 output | ||||
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 34 | ' |
35 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 36 | test_expect_success 'verify untarred file-5' ' |
37 | grep "^5$" master/file-5 && | ||||
38 | test_line_count = 1 master/file-5 | ||||
Lars Hjemli | b4649fc | 2007-11-11 00:40:58 +0100 | [diff] [blame] | 39 | ' |
40 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 41 | test_expect_success 'get foo/snapshot/master.zip' ' |
42 | cgit_url "foo/snapshot/master.zip" >tmp | ||||
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 43 | ' |
44 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 45 | test_expect_success 'check HTML headers (zip)' ' |
46 | head -n 1 tmp | | ||||
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 47 | grep "Content-Type: application/x-zip" && |
48 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 49 | head -n 2 tmp | |
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 50 | grep "Content-Disposition: inline; filename=.master.zip." |
51 | ' | ||||
52 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 53 | test_expect_success 'strip off the header lines (zip)' ' |
John Keeping | 75bfec6 | 2013-05-18 18:46:38 +0100 | [diff] [blame] | 54 | strip_headers <tmp >master.zip |
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 55 | ' |
56 | |||||
Lukas Fleischer | 81bf4d3 | 2013-04-09 20:02:33 +0200 | [diff] [blame] | 57 | if test -n "$(which unzip 2>/dev/null)"; then |
58 | test_set_prereq UNZIP | ||||
59 | else | ||||
60 | say 'Skipping ZIP validation tests: unzip not found' | ||||
61 | fi | ||||
62 | |||||
63 | test_expect_success UNZIP 'verify zip format' ' | ||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 64 | unzip -t master.zip |
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 65 | ' |
66 | |||||
Lukas Fleischer | 81bf4d3 | 2013-04-09 20:02:33 +0200 | [diff] [blame] | 67 | test_expect_success UNZIP 'unzip' ' |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 68 | rm -rf master && |
69 | unzip master.zip | ||||
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 70 | ' |
71 | |||||
Lukas Fleischer | 81bf4d3 | 2013-04-09 20:02:33 +0200 | [diff] [blame] | 72 | test_expect_success UNZIP 'count files (zip)' ' |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 73 | ls master/ >output && |
74 | test_line_count = 5 output | ||||
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 75 | ' |
76 | |||||
Lukas Fleischer | 81bf4d3 | 2013-04-09 20:02:33 +0200 | [diff] [blame] | 77 | test_expect_success UNZIP 'verify unzipped file-5' ' |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 78 | grep "^5$" master/file-5 && |
79 | test_line_count = 1 master/file-5 | ||||
John Keeping | d5a43b4 | 2013-03-04 21:58:51 +0000 | [diff] [blame] | 80 | ' |
81 | |||||
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 82 | test_done |