Merge branch 'cw/ci-ghwf-check-ws-errors'
[git] / t / t5411 / test-0020-report-ng.sh
1 test_expect_success "setup proc-receive hook (ng, no message, $PROTOCOL)" '
2         write_script "$upstream/hooks/proc-receive" <<-EOF
3         printf >&2 "# proc-receive hook\n"
4         test-tool proc-receive -v \
5                 -r "ng refs/for/main/topic"
6         EOF
7 '
8
9 # Refs of upstream : main(A)
10 # Refs of workbench: main(A)  tags/v123
11 # git push         :                       refs/for/main/topic
12 test_expect_success "proc-receive: fail to update (ng, no message, $PROTOCOL)" '
13         test_must_fail git -C workbench push origin \
14                 HEAD:refs/for/main/topic \
15                 >out 2>&1 &&
16         make_user_friendly_and_stable_output <out >actual &&
17         cat >expect <<-EOF &&
18         remote: # pre-receive hook
19         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
20         remote: # proc-receive hook
21         remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
22         remote: proc-receive> ng refs/for/main/topic
23         To <URL/of/upstream.git>
24          ! [remote rejected] HEAD -> refs/for/main/topic (failed)
25         EOF
26         test_cmp expect actual &&
27         git -C "$upstream" show-ref >out &&
28         make_user_friendly_and_stable_output <out >actual &&
29         cat >expect <<-EOF &&
30         <COMMIT-A> refs/heads/main
31         EOF
32         test_cmp expect actual
33 '
34
35 test_expect_success "setup proc-receive hook (ng message, $PROTOCOL)" '
36         write_script "$upstream/hooks/proc-receive" <<-EOF
37         printf >&2 "# proc-receive hook\n"
38         test-tool proc-receive -v \
39                 -r "ng refs/for/main/topic error msg"
40         EOF
41 '
42
43 # Refs of upstream : main(A)
44 # Refs of workbench: main(A)  tags/v123
45 # git push         :                       refs/for/main/topic
46 test_expect_success "proc-receive: fail to update (ng, with message, $PROTOCOL)" '
47         test_must_fail git -C workbench push origin \
48                 HEAD:refs/for/main/topic \
49                 >out 2>&1 &&
50         make_user_friendly_and_stable_output <out >actual &&
51         cat >expect <<-EOF &&
52         remote: # pre-receive hook
53         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
54         remote: # proc-receive hook
55         remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
56         remote: proc-receive> ng refs/for/main/topic error msg
57         To <URL/of/upstream.git>
58          ! [remote rejected] HEAD -> refs/for/main/topic (error msg)
59         EOF
60         test_cmp expect actual &&
61         git -C "$upstream" show-ref >out &&
62         make_user_friendly_and_stable_output <out >actual &&
63         cat >expect <<-EOF &&
64         <COMMIT-A> refs/heads/main
65         EOF
66         test_cmp expect actual
67 '