t/t5528-push-default: test pushdefault workflows

Introduce test_pushdefault_workflows(), and test that all push.default modes work with central and triangular workflows as expected. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 19, 2013 at 16:41 UTC 6e1696b7c46f02310a882b4e761a29d3a0cf278f
1 file changed +57
t/t5528-push-default.sh
+57
@@ -39,6 +39,26 @@ test_push_failure () {
39 test_cmp expect actual
40 }
41
42 +# $1 = success or failure
43 +# $2 = push.default value
44 +# $3 = branch to check for actual output (master or foo)
45 +# $4 = [optional] switch to triangular workflow
46 +test_pushdefault_workflow () {
47 + workflow=central
48 + pushdefault=parent1
49 + if test -n "${4-}"; then
50 + workflow=triangular
51 + pushdefault=parent2
52 + fi
53 + test_expect_success "push.default = $2 $1 in $workflow workflows" "
54 + test_config branch.master.remote parent1 &&
55 + test_config branch.master.merge refs/heads/foo &&
56 + test_config remote.pushdefault $pushdefault &&
57 + test_commit commit-for-$2${4+-triangular} &&
58 + test_push_$1 $2 $3 ${4+repo2}
59 + "
60 +}
61 +
62 test_expect_success '"upstream" pushes to configured upstream' '
63 git checkout master &&
64 test_config branch.master.remote parent1 &&
@@ -115,4 +135,41 @@ test_expect_success 'push to existing branch, upstream configured with different
135 test_cmp expect-other-name actual-other-name
136 '
137
138 +# We are on 'master', which integrates with 'foo' from parent1
139 +# remote (set in test_pushdefault_workflow helper). Push to
140 +# parent1 in centralized, and push to parent2 in triangular workflow.
141 +# The parent1 repository has 'master' and 'foo' branches, while
142 +# the parent2 repository has only 'master' branch.
143 +#
144 +# test_pushdefault_workflow() arguments:
145 +# $1 = success or failure
146 +# $2 = push.default value
147 +# $3 = branch to check for actual output (master or foo)
148 +# $4 = [optional] switch to triangular workflow
149 +
150 +# update parent1's master (which is not our upstream)
151 +test_pushdefault_workflow success current master
152 +
153 +# update parent1's foo (which is our upstream)
154 +test_pushdefault_workflow success upstream foo
155 +
156 +# upsream is foo which is not the name of the current branch
157 +test_pushdefault_workflow failure simple master
158 +
159 +# master and foo are updated
160 +test_pushdefault_workflow success matching master
161 +
162 +# master is updated
163 +test_pushdefault_workflow success current master triangular
164 +
165 +# upstream mode cannot be used in triangular
166 +test_pushdefault_workflow failure upstream foo triangular
167 +
168 +# in triangular, 'simple' works as 'current' and update the branch
169 +# with the same name.
170 +test_pushdefault_workflow success simple master triangular
171 +
172 +# master is updated (parent2 does not have foo)
173 +test_pushdefault_workflow success matching master triangular
174 +
175 test_done