Skip to content

Commit

Permalink
push test: use test_config when appropriate
Browse files Browse the repository at this point in the history
Configuration from test_config does not last beyond the end of the
current test assertion, making each test easier to think about in
isolation.

This changes the meaning of some of the tests.  For example, currently
"push with insteadOf" passes even if the line setting
"url.$TRASH.pushInsteadOf" is dropped because an url.$TRASH.insteadOf
setting leaks in from a previous test.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Mar 19, 2013
1 parent 239222f commit 3c69552
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions t/t5516-fetch-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ test_expect_success 'push with wildcard' '
test_expect_success 'push with insteadOf' '
mk_empty &&
TRASH="$(pwd)/" &&
git config "url.$TRASH.insteadOf" trash/ &&
test_config "url.$TRASH.insteadOf" trash/ &&
git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
Expand All @@ -217,7 +217,7 @@ test_expect_success 'push with insteadOf' '
test_expect_success 'push with pushInsteadOf' '
mk_empty &&
TRASH="$(pwd)/" &&
git config "url.$TRASH.pushInsteadOf" trash/ &&
test_config "url.$TRASH.pushInsteadOf" trash/ &&
git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
Expand All @@ -231,9 +231,9 @@ test_expect_success 'push with pushInsteadOf' '
test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
mk_empty &&
TRASH="$(pwd)/" &&
git config "url.trash2/.pushInsteadOf" trash/ &&
git config remote.r.url trash/wrong &&
git config remote.r.pushurl "$TRASH/testrepo" &&
test_config "url.trash2/.pushInsteadOf" trash/ &&
test_config remote.r.url trash/wrong &&
test_config remote.r.pushurl "$TRASH/testrepo" &&
git push r refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
Expand Down Expand Up @@ -489,31 +489,24 @@ test_expect_success 'push with config remote.*.push = HEAD' '
git checkout local &&
git reset --hard $the_first_commit
) &&
git config remote.there.url testrepo &&
git config remote.there.push HEAD &&
git config branch.master.remote there &&
test_config remote.there.url testrepo &&
test_config remote.there.push HEAD &&
test_config branch.master.remote there &&
git push &&
check_push_result $the_commit heads/master &&
check_push_result $the_first_commit heads/local
'

# clean up the cruft left with the previous one
git config --remove-section remote.there
git config --remove-section branch.master

test_expect_success 'push with config remote.*.pushurl' '
mk_test heads/master &&
git checkout master &&
git config remote.there.url test2repo &&
git config remote.there.pushurl testrepo &&
test_config remote.there.url test2repo &&
test_config remote.there.pushurl testrepo &&
git push there &&
check_push_result $the_commit heads/master
'

# clean up the cruft left with the previous one
git config --remove-section remote.there

test_expect_success 'push with dry-run' '
mk_test heads/master &&
Expand Down

0 comments on commit 3c69552

Please sign in to comment.