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 <trast@inf.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Apr 24, 2013 at 15:54 UTC
abf5f8723cc65c499eb6b65b07bd935f43525b24
1 file changed
+27
t/t5505-remote.sh
+27
@@ -1003,4 +1003,31 @@ test_expect_success 'remote set-url --delete baz' '
1003
cmp expect actual
1004
'
1005
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
+
1033
test_done