Skip to content

Commit fd0a8c2

Browse files
Tarmigan Caseboltgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04481ad commit fd0a8c2

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

t/t5560-http-backend-noserver.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,34 @@ test_description='test git-http-backend-noserver'
66
HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY"
77

88
run_backend() {
9-
REQUEST_METHOD=GET \
9+
echo "$2" |
10+
QUERY_STRING="${1#*\?}" \
1011
GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \
11-
PATH_INFO="$1" \
12+
PATH_INFO="${1%%\?*}" \
1213
git http-backend >act.out 2>act.err
1314
}
1415

1516
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
1725
}
1826

1927
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
2137
}
2238

2339
log_div() {
@@ -28,9 +44,9 @@ log_div() {
2844

2945
expect_aliased() {
3046
if test $1 = 0; then
31-
run_backend "$2"
47+
REQUEST_METHOD=GET run_backend "$2"
3248
else
33-
run_backend "$2" &&
49+
REQUEST_METHOD=GET run_backend "$2" &&
3450
echo "fatal: '$2': aliased" >exp.err &&
3551
test_cmp exp.err act.err
3652
fi

t/t556x_common

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ get_static_files() {
5050
}
5151

5252
SMART=smart
53+
export GIT_HTTP_EXPORT_ALL=1
5354
test_expect_success 'direct refs/heads/master not found' '
5455
log_div "refs/heads/master"
5556
GET refs/heads/master "404 Not Found"
@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '
5960
get_static_files "200 OK"
6061
'
6162
SMART=smart_noexport
63+
unset GIT_HTTP_EXPORT_ALL
6264
test_expect_success 'no export by default' '
6365
log_div "no git-daemon-export-ok"
6466
get_static_files "404 Not Found"
@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
7173
get_static_files "200 OK"
7274
'
7375
SMART=smart
76+
export GIT_HTTP_EXPORT_ALL=1
7477
test_expect_success 'static file if http.getanyfile true is ok' '
7578
log_div "getanyfile true"
7679
config http.getanyfile true &&

0 commit comments

Comments
 (0)