summaryrefslogtreecommitdiff
path: root/t/t5411/test-0013-bad-protocol.sh
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <zhiyou.jx@alibaba-inc.com>2021-01-20 21:53:31 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-01-22 13:09:06 -0800
commit822ee894f621674610a36cc9a84a9ffbbb8fb6bb (patch)
tree70c3efa9e94bacf13970a1ae8681b4a24e155615 /t/t5411/test-0013-bad-protocol.sh
parentt5411: use different out file to prevent overwriting (diff)
downloadtgif-822ee894f621674610a36cc9a84a9ffbbb8fb6bb.tar.xz
t5411: refactor check of refs using test_cmp_refs
Add new helper 'test_cmp_refs' to check references in a repository. Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5411/test-0013-bad-protocol.sh')
-rw-r--r--t/t5411/test-0013-bad-protocol.sh45
1 files changed, 9 insertions, 36 deletions
diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh
index bddface163..095e613f6f 100644
--- a/t/t5411/test-0013-bad-protocol.sh
+++ b/t/t5411/test-0013-bad-protocol.sh
@@ -34,12 +34,9 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" '
EOF
test_cmp expect actual-error &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL)" '
@@ -68,12 +65,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTO
grep "remote: fatal: die with the --die-read-version option" out-$test_count &&
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL)" '
@@ -102,12 +96,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROT
grep "remote: fatal: die with the --die-write-version option" out-$test_count &&
grep "remote: error: fail to negotiate version with proc-receive hook" out-$test_count &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL)" '
@@ -135,12 +126,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROT
test_cmp expect actual &&
grep "remote: fatal: die with the --die-read-commands option" out-$test_count &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL)" '
@@ -170,12 +158,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $
test_cmp expect actual &&
grep "remote: fatal: die with the --die-read-push-options option" out-$test_count &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL)" '
@@ -203,12 +188,9 @@ test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTO
test_cmp expect actual &&
grep "remote: fatal: die with the --die-write-report option" out-$test_count &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (no report, $PROTOCOL)" '
@@ -240,13 +222,10 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" '
EOF
test_cmp expect actual &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
<COMMIT-A> refs/heads/next
EOF
- test_cmp expect actual
'
# Refs of upstream : main(A) next(A)
@@ -284,12 +263,9 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" '
EOF
test_cmp expect actual &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'
test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL)" '
@@ -320,10 +296,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" '
EOF
test_cmp expect actual &&
- git -C "$upstream" show-ref >out &&
- make_user_friendly_and_stable_output <out >actual &&
- cat >expect <<-EOF &&
+ test_cmp_refs -C "$upstream" <<-EOF
<COMMIT-A> refs/heads/main
EOF
- test_cmp expect actual
'