]> git.cameronkatri.com Git - cgit.git/blob - tests/t0107-snapshot.sh
tests: introduce strip_header() helper function
[cgit.git] / tests / t0107-snapshot.sh
1 #!/bin/sh
2
3 test_description='Verify snapshot'
4 . ./setup.sh
5
6 test_expect_success 'get foo/snapshot/master.tar.gz' '
7 cgit_url "foo/snapshot/master.tar.gz" >tmp
8 '
9
10 test_expect_success 'check html headers' '
11 head -n 1 tmp |
12 grep "Content-Type: application/x-gzip" &&
13
14 head -n 2 tmp |
15 grep "Content-Disposition: inline; filename=.master.tar.gz."
16 '
17
18 test_expect_success 'strip off the header lines' '
19 strip_headers <tmp >master.tar.gz
20 '
21
22 test_expect_success 'verify gzip format' '
23 gunzip --test master.tar.gz
24 '
25
26 test_expect_success 'untar' '
27 rm -rf master &&
28 tar -xzf master.tar.gz
29 '
30
31 test_expect_success 'count files' '
32 ls master/ >output &&
33 test_line_count = 5 output
34 '
35
36 test_expect_success 'verify untarred file-5' '
37 grep "^5$" master/file-5 &&
38 test_line_count = 1 master/file-5
39 '
40
41 test_expect_success 'get foo/snapshot/master.zip' '
42 cgit_url "foo/snapshot/master.zip" >tmp
43 '
44
45 test_expect_success 'check HTML headers (zip)' '
46 head -n 1 tmp |
47 grep "Content-Type: application/x-zip" &&
48
49 head -n 2 tmp |
50 grep "Content-Disposition: inline; filename=.master.zip."
51 '
52
53 test_expect_success 'strip off the header lines (zip)' '
54 strip_headers <tmp >master.zip
55 '
56
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' '
64 unzip -t master.zip
65 '
66
67 test_expect_success UNZIP 'unzip' '
68 rm -rf master &&
69 unzip master.zip
70 '
71
72 test_expect_success UNZIP 'count files (zip)' '
73 ls master/ >output &&
74 test_line_count = 5 output
75 '
76
77 test_expect_success UNZIP 'verify unzipped file-5' '
78 grep "^5$" master/file-5 &&
79 test_line_count = 1 master/file-5
80 '
81
82 test_done