Remove the server-/client- prefixes in the tests.
[git-central.git] / tests / t2000-update-ensure-ticket-reference.sh
1 #!/bin/sh
2
3 test_description='server update trac ticket enforcer'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo This is a test. >a &&
9         git add a &&
10         git commit -m "a" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git remote add origin ./server &&
14         git config --add branch.master.remote origin &&
15         git config --add branch.master.merge refs/heads/master
16 '
17
18 # setup the update hook
19 install_update_hook 'update-ensure-ticket-reference'
20
21 test_expect_success 'reject with bad message' '
22         echo $test_name >a &&
23         git commit -a -m "$test_name" &&
24         head=$(git rev-parse HEAD) &&
25         ! git push 2>push.err &&
26         cat push.err | grep "Commit $head does not reference a ticket"
27 '
28
29 # the last test has a dirty commit message, so ammend it with a good message
30 test_expect_success 'accept with re' '
31         echo $test_name >a &&
32         git commit --amend -m "$test_name re #3222" &&
33         git push
34 '
35
36 test_expect_success 'accept with re on second line' '
37         echo $test_name >a &&
38         echo "first subject line" >msg
39         echo "second line re #322" >>msg
40         git commit -a -F msg &&
41         git push
42 '
43
44 test_expect_success 'reject with bad message in second of three' '
45         echo "$test_name first" >a &&
46         git commit -a -m "$test_name first re #3222" &&
47
48         # the bad one
49         echo "$test_name second" >a &&
50         git commit -a -m "$test_name second" &&
51         head=$(git rev-parse HEAD) &&
52         echo "head=$head" &&
53
54         echo "$test_name third" >a &&
55         git commit -a -m "$test_name third re #3222" &&
56
57         ! git push 2>push.err &&
58         cat push.err | grep "Commit $head does not reference a ticket"
59 '
60
61 test_expect_success 'accept with re in all of three' '
62         git reset --hard HEAD^^^ &&
63         echo "$test_name first" >a &&
64         git commit -a -m "$test_name first re #3222" &&
65
66         # the bad one
67         echo "$test_name second" >a &&
68         git commit -a -m "$test_name second re #3222" &&
69         head=$(git rev-parse HEAD) &&
70
71         echo "$test_name third" >a &&
72         git commit -a -m "$test_name third re #3222" &&
73
74         git push
75 '
76
77 test_done
78