all repos — cgit @ 06671f4b2167951c6b46401b0f5ac8af4d48d50a

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	cp master.tar.lz /tmp/.
 66'
 67
 68test_expect_success LZIP 'untar' '
 69	rm -rf master &&
 70	tar --lzip -xf master.tar.lz
 71'
 72
 73test_expect_success LZIP 'count files' '
 74	ls master/ >output &&
 75	test_line_count = 5 output
 76'
 77
 78test_expect_success LZIP 'verify untarred file-5' '
 79	grep "^5$" master/file-5 &&
 80	test_line_count = 1 master/file-5
 81'
 82
 83test_expect_success 'get foo/snapshot/master.zip' '
 84	cgit_url "foo/snapshot/master.zip" >tmp
 85'
 86
 87test_expect_success 'check HTML headers (zip)' '
 88	head -n 1 tmp |
 89	grep "Content-Type: application/x-zip" &&
 90
 91	head -n 2 tmp |
 92	grep "Content-Disposition: inline; filename=.master.zip."
 93'
 94
 95test_expect_success 'strip off the header lines (zip)' '
 96	strip_headers <tmp >master.zip
 97'
 98
 99if test -n "$(which unzip 2>/dev/null)"; then
100	test_set_prereq UNZIP
101else
102	say 'Skipping ZIP validation tests: unzip not found'
103fi
104
105test_expect_success UNZIP 'verify zip format' '
106	unzip -t master.zip
107'
108
109test_expect_success UNZIP 'unzip' '
110	rm -rf master &&
111	unzip master.zip
112'
113
114test_expect_success UNZIP 'count files (zip)' '
115	ls master/ >output &&
116	test_line_count = 5 output
117'
118
119test_expect_success UNZIP 'verify unzipped file-5' '
120	grep "^5$" master/file-5 &&
121	test_line_count = 1 master/file-5
122'
123
124test_done