t554[01]-http-push: refactor, add non-ff tests
Move non-fast forward tests to lib-httpd.sh so that we don't have to duplicate the tests in both t5540 and t5541. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tay Ray Chuan committed
Mar 2, 2010 at 18:49 UTC
6cbd6e92616773457574f9755910f44b3c34a983
3 files changed
+34
-22
t/lib-httpd.sh
+29
@@ -131,3 +131,32 @@ stop_httpd() {
131
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
132
-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
133
}
134
+
135
+test_http_push_nonff() {
136
+ REMOTE_REPO=$1
137
+ LOCAL_REPO=$2
138
+ BRANCH=$3
139
+
140
+ test_expect_success 'non-fast-forward push fails' '
141
+ cd "$REMOTE_REPO" &&
142
+ HEAD=$(git rev-parse --verify HEAD) &&
143
+
144
+ cd "$LOCAL_REPO" &&
145
+ git checkout $BRANCH &&
146
+ echo "changed" > path2 &&
147
+ git commit -a -m path2 --amend &&
148
+
149
+ !(git push -v origin >output 2>&1) &&
150
+ (cd "$REMOTE_REPO" &&
151
+ test $HEAD = $(git rev-parse --verify HEAD))
152
+ '
153
+
154
+ test_expect_success 'non-fast-forward push show ref status' '
155
+ grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output
156
+ '
157
+
158
+ test_expect_success 'non-fast-forward push shows help message' '
159
+ grep "To prevent you from losing history, non-fast-forward updates were rejected" \
160
+ output
161
+ '
162
+}
t/t5540-http-push.sh
+3
@@ -137,6 +137,9 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
137
138
'
139
140
+test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
141
+ "$ROOT_PATH"/test_repo_clone master
142
+
143
stop_httpd
144
145
test_done
t/t5541-http-push.sh
+2
-22
@@ -88,28 +88,8 @@ test_expect_success 'used receive-pack service' '
88
test_cmp exp act
89
'
90
91
-test_expect_success 'non-fast-forward push fails' '
92
- cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
93
- HEAD=$(git rev-parse --verify HEAD) &&
94
-
95
- cd "$ROOT_PATH"/test_repo_clone &&
96
- git checkout master &&
97
- echo "changed" > path2 &&
98
- git commit -a -m path2 --amend &&
99
-
100
- !(git push -v origin >output 2>&1) &&
101
- (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
102
- test $HEAD = $(git rev-parse --verify HEAD))
103
-'
104
-
105
-test_expect_success 'non-fast-forward push show ref status' '
106
- grep "^ ! \[rejected\][ ]*master -> master (non-fast-forward)$" output
107
-'
108
-
109
-test_expect_success 'non-fast-forward push shows help message' '
110
- grep "To prevent you from losing history, non-fast-forward updates were rejected" \
111
- output
112
-'
91
+test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
92
+ "$ROOT_PATH"/test_repo_clone master
93
94
test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
95
# create a dissimilarly-named remote ref so that git is unable to match the