all repos — cgit @ a1039ab17591cc531c877bc693088fd2e45c97ff

a hyperfast web frontend for git written in c

tests/t0107-snapshot.sh (view raw)

  1#!/bin/sh
  2
  3test_description='Verify snapshot'
  4. ./setup.sh
  5
  6test_expect_success 'get foo/snapshot/master.tar.gz' '
  7	cgit_url "foo/snapshot/master.tar.gz" >tmp
  8'
  9
 10test_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
 18test_expect_success 'strip off the header lines' '
 19	strip_headers <tmp >master.tar.gz
 20'
 21
 22test_expect_success 'verify gzip format' '
 23	gunzip --test master.tar.gz
 24'
 25
 26test_expect_success 'untar' '
 27	rm -rf master &&
 28	tar -xzf master.tar.gz
 29'
 30
 31test_expect_success 'count files' '
 32	ls master/ >output &&
 33	test_line_count = 5 output
 34'
 35
 36test_expect_success 'verify untarred file-5' '
 37	grep "^5$" master/file-5 &&
 38	test_line_count = 1 master/file-5
 39'
 40
 41if test -n "$(which lzip 2>/dev/null)"; then
 42	test_set_prereq LZIP
 43else
 44	say 'Skipping LZIP validation tests: lzip not found'
 45fi
 46
 47test_expect_success LZIP 'get foo/snapshot/master.tar.lz' '
 48	cgit_url "foo/snapshot/master.tar.lz" >tmp
 49'
 50
 51test_expect_success LZIP 'check html headers' '
 52	head -n 1 tmp |
 53	grep "Content-Type: application/x-lzip" &&
 54
 55	head -n 2 tmp |
 56	grep "Content-Disposition: inline; filename=.master.tar.lz."
 57'
 58
 59test_expect_success LZIP 'strip off the header lines' '
 60	strip_headers <tmp >master.tar.lz
 61'
 62
 63test_expect_success LZIP 'verify lzip format' '
 64	lzip --test master.tar.lz
 65'
 66
 67test_expect_success LZIP 'untar' '
 68	rm -rf master &&
 69	tar --lzip -xf master.tar.lz
 70'
 71
 72test_expect_success LZIP 'count files' '
 73	ls master/ >output &&
 74	test_line_count = 5 output
 75'
 76
 77test_expect_success LZIP 'verify untarred file-5' '
 78	grep "^5$" master/file-5 &&
 79	test_line_count = 1 master/file-5
 80'
 81
 82if test -n "$(which xz 2>/dev/null)"; then
 83	test_set_prereq XZ
 84else
 85	say 'Skipping XZ validation tests: xz not found'
 86fi
 87
 88test_expect_success XZ 'get foo/snapshot/master.tar.xz' '
 89	cgit_url "foo/snapshot/master.tar.xz" >tmp
 90'
 91
 92test_expect_success XZ 'check html headers' '
 93	head -n 1 tmp |
 94	grep "Content-Type: application/x-xz" &&
 95
 96	head -n 2 tmp |
 97	grep "Content-Disposition: inline; filename=.master.tar.xz."
 98'
 99
100test_expect_success XZ 'strip off the header lines' '
101	strip_headers <tmp >master.tar.xz
102'
103
104test_expect_success XZ 'verify xz format' '
105	xz --test master.tar.xz
106'
107
108test_expect_success XZ 'untar' '
109	rm -rf master &&
110	tar --xz -xf master.tar.xz
111'
112
113test_expect_success XZ 'count files' '
114	ls master/ >output &&
115	test_line_count = 5 output
116'
117
118test_expect_success XZ 'verify untarred file-5' '
119	grep "^5$" master/file-5 &&
120	test_line_count = 1 master/file-5
121'
122
123if test -n "$(which zstd 2>/dev/null)"; then
124	test_set_prereq ZSTD
125else
126	say 'Skipping ZSTD validation tests: zstd not found'
127fi
128
129test_expect_success ZSTD 'get foo/snapshot/master.tar.zst' '
130	cgit_url "foo/snapshot/master.tar.zst" >tmp
131'
132
133test_expect_success ZSTD 'check html headers' '
134	head -n 1 tmp |
135	grep "Content-Type: application/x-zstd" &&
136
137	head -n 2 tmp |
138	grep "Content-Disposition: inline; filename=.master.tar.zst."
139'
140
141test_expect_success ZSTD 'strip off the header lines' '
142	strip_headers <tmp >master.tar.zst
143'
144
145test_expect_success ZSTD 'verify zstd format' '
146	zstd --test master.tar.zst
147'
148
149test_expect_success ZSTD 'untar' '
150	rm -rf master &&
151	tar --zstd -xf master.tar.zst
152'
153
154test_expect_success ZSTD 'count files' '
155	ls master/ >output &&
156	test_line_count = 5 output
157'
158
159test_expect_success ZSTD 'verify untarred file-5' '
160	grep "^5$" master/file-5 &&
161	test_line_count = 1 master/file-5
162'
163
164test_expect_success 'get foo/snapshot/master.zip' '
165	cgit_url "foo/snapshot/master.zip" >tmp
166'
167
168test_expect_success 'check HTML headers (zip)' '
169	head -n 1 tmp |
170	grep "Content-Type: application/x-zip" &&
171
172	head -n 2 tmp |
173	grep "Content-Disposition: inline; filename=.master.zip."
174'
175
176test_expect_success 'strip off the header lines (zip)' '
177	strip_headers <tmp >master.zip
178'
179
180if test -n "$(which unzip 2>/dev/null)"; then
181	test_set_prereq UNZIP
182else
183	say 'Skipping ZIP validation tests: unzip not found'
184fi
185
186test_expect_success UNZIP 'verify zip format' '
187	unzip -t master.zip
188'
189
190test_expect_success UNZIP 'unzip' '
191	rm -rf master &&
192	unzip master.zip
193'
194
195test_expect_success UNZIP 'count files (zip)' '
196	ls master/ >output &&
197	test_line_count = 5 output
198'
199
200test_expect_success UNZIP 'verify unzipped file-5' '
201	grep "^5$" master/file-5 &&
202	test_line_count = 1 master/file-5
203'
204
205test_done