@matheusbsbs / matheus-bagliano / commits / fd0a8c2e64
Fork 0

Smart-http tests: Test http-backend without curl or a webserver

This reuses many of the tests from the old t5560 but runs those tests without curl or a webserver. This will hopefully increase the testing coverage for http-backend because it does not require users to set GIT_TEST_HTTPD. Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tarmigan Casebolt committed Jan 2, 2010 at 13:43 UTC fd0a8c2e6428acb883bf4707de54b3e026c57455
2 files changed +25 -6
t/t5560-http-backend-noserver.sh
+22 -6
@@ -6,18 +6,34 @@ test_description='test git-http-backend-noserver'
6 HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
7
8 run_backend() {
9 - REQUEST_METHOD=GET \
9 + echo "$2" |
10 + QUERY_STRING="${1#*\?}" \
11 GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
11 - PATH_INFO="$1" \
12 + PATH_INFO="${1%%\?*}" \
13 git http-backend >act.out 2>act.err
14 }
15
16 GET() {
16 - return 0
17 + REQUEST_METHOD="GET" \
18 + run_backend "/repo.git/$1" &&
19 + if ! grep "Status" act.out >act
20 + then
21 + printf "Status: 200 OK\r\n" >act
22 + fi
23 + printf "Status: $2\r\n" >exp &&
24 + test_cmp exp act
25 }
26
27 POST() {
20 - return 0
28 + REQUEST_METHOD="POST" \
29 + CONTENT_TYPE="application/x-$1-request" \
30 + run_backend "/repo.git/$1" "$2" &&
31 + if ! grep "Status" act.out >act
32 + then
33 + printf "Status: 200 OK\r\n" >act
34 + fi
35 + printf "Status: $3\r\n" >exp &&
36 + test_cmp exp act
37 }
38
39 log_div() {
@@ -28,9 +44,9 @@ log_div() {
44
45 expect_aliased() {
46 if test $1 = 0; then
31 - run_backend "$2"
47 + REQUEST_METHOD=GET run_backend "$2"
48 else
33 - run_backend "$2" &&
49 + REQUEST_METHOD=GET run_backend "$2" &&
50 echo "fatal: '$2': aliased" >exp.err &&
51 test_cmp exp.err act.err
52 fi
t/t556x_common
+3
@@ -50,6 +50,7 @@ get_static_files() {
50 }
51
52 SMART=smart
53 +export GIT_HTTP_EXPORT_ALL=1
54 test_expect_success 'direct refs/heads/master not found' '
55 log_div "refs/heads/master"
56 GET refs/heads/master "404 Not Found"
@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '
60 get_static_files "200 OK"
61 '
62 SMART=smart_noexport
63 +unset GIT_HTTP_EXPORT_ALL
64 test_expect_success 'no export by default' '
65 log_div "no git-daemon-export-ok"
66 get_static_files "404 Not Found"
@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
73 get_static_files "200 OK"
74 '
75 SMART=smart
76 +export GIT_HTTP_EXPORT_ALL=1
77 test_expect_success 'static file if http.getanyfile true is ok' '
78 log_div "getanyfile true"
79 config http.getanyfile true &&