# [RFC/PATCH 3/3] gitweb: add test cases for snapshot settings

2 messages from 2009-08-23 to 2009-08-24. Participants: Mark Rada, Jakub Narebski.
Thread: https://gitlist.dev/t/20712

## Mark Rada, 2009-08-23 21:53

Subject: [RFC/PATCH 3/3] gitweb: add test cases for snapshot settings
Message-ID: <4A91BA53.1040800@mailservices.uwaterloo.ca>
URL: https://gitlist.dev/e/4A91BA53.1040800%40mailservices.uwaterloo.ca

```
This commit adds a new test file (t9501) that is used for gitweb test
cases that parse gitweb output to verify the HTTP status code or
message.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
 t/t9501-gitweb-standalone-http-status.sh |   71 ++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 t/t9501-gitweb-standalone-http-status.sh

diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh
new file mode 100644
index 0000000..c4b0479
--- /dev/null
+++ b/t/t9501-gitweb-standalone-http-status.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Mark Rada
+#
+
+. ./gitweb-lib.sh
+
+# ----------------------------------------------------------------------
+# snapshot settings
+
+test_commit \
+	'SnapshotTest' \
+	'i can has snapshot?'
+
+cat >>gitweb_config.perl <<\EOF
+$feature{'snapshot'}{'override'} = 0;
+EOF
+
+test_expect_success \
+    'snapshots: tgz only default format enabled' \
+    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
+    grep "Status: 200 OK" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
+    grep "403 - Unsupported snapshot format" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
+    grep "403 - Snapshot format not allowed" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
+    grep "403 - Unsupported snapshot format" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
+cat >>gitweb_config.perl <<\EOF
+$feature{'snapshot'}{'default'} = ['tgz','tbz2','txz','zip'];
+EOF
+
+test_expect_success \
+    'snapshots: all enabled in default, use default disabled value' \
+    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
+    grep "Status: 200 OK" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tbz2" &&
+    grep "Status: 200 OK" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=txz" &&
+    grep "403 - Snapshot format not allowed" gitweb.output &&
+    gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
+    grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
+cat >>gitweb_config.perl <<\EOF
+$known_snapshot_formats{'zip'}{'disabled'} = 1;
+EOF
+
+test_expect_success \
+    'snapshots: zip explicitly disabled' \
+    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" &&
+    grep "403 - Snapshot format not allowed" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
+cat >>gitweb_config.perl <<\EOF
+$known_snapshot_formats{'tgz'}{'disabled'} = 0;
+EOF
+
+test_expect_success \
+    'snapshots: tgz explicitly enabled' \
+    'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
+    grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
+test_done 
-- 
1.6.4

```

## Jakub Narebski, 2009-08-24 12:36

Subject: Re: [RFC/PATCH 3/3] gitweb: add test cases for snapshot settings
Message-ID: <200908241436.13626.jnareb@gmail.com>
URL: https://gitlist.dev/e/200908241436.13626.jnareb%40gmail.com
In-Reply-To: <4A91BA53.1040800@mailservices.uwaterloo.ca>

```
On Sun, 23 Aug 2009, Mark Rada wrote:

> This commit adds a new test file (t9501) that is used for gitweb test
> cases that parse gitweb output to verify the HTTP status code or
> message.
> 
> Signed-off-by: Mark Rada <marada@uwaterloo.ca>
> ---

I would rather put emphasis on the fact that new test is created, which
is meant to check that gitweb produces expected HTTP status codes.

-- >8 --
Subject: gitweb: Add t9501 test for gitweb's HTTP status codes

This commit adds a new test file (t9501), that is used for gitweb test
cases that parse gitweb output to verify the HTTP status code or
message.

Currently the only tests are about 'snapshot' feature settings
-- [end cut] --

Or something like that.
-- 
Jakub Narebski
Poland

```
