Skip to content

Commit abf5f87

Browse files
Thomas Rastgitster
authored andcommitted
remote: add a test for extra arguments, according to docs
This adds one test or comment for each subcommand of git-remote according to its current documentation. All but 'set-branches' and 'update' are listed as taking only a fixed number of arguments; for those we can write a test with one more (bogus) argument, and see if the command notices that. They fail on several counts: 'add' does not check for extra arguments, and 'show' and 'prune' actually iterate over remotes (i.e., take any number of args). We'll fix them in the next two patches. The -f machinery is only there to make the tests readable while still ensuring they pass as a whole, and will be removed in the final patch. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e7bb5d commit abf5f87

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/t5505-remote.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,4 +1003,31 @@ test_expect_success 'remote set-url --delete baz' '
10031003
cmp expect actual
10041004
'
10051005

1006+
test_expect_success 'extra args: setup' '
1007+
# add a dummy origin so that this does not trigger failure
1008+
git remote add origin .
1009+
'
1010+
1011+
test_extra_arg () {
1012+
expect="success"
1013+
if test "z$1" = "z-f"; then
1014+
expect=failure
1015+
shift
1016+
fi
1017+
test_expect_$expect "extra args: $*" "
1018+
test_must_fail git remote $* bogus_extra_arg 2>actual &&
1019+
grep '^usage:' actual
1020+
"
1021+
}
1022+
1023+
test_extra_arg -f add nick url
1024+
test_extra_arg rename origin newname
1025+
test_extra_arg remove origin
1026+
test_extra_arg set-head origin master
1027+
# set-branches takes any number of args
1028+
test_extra_arg set-url origin newurl oldurl
1029+
test_extra_arg -f show origin
1030+
test_extra_arg -f prune origin
1031+
# update takes any number of args
1032+
10061033
test_done

0 commit comments

Comments
 (0)