remote: add tests for add and rename with invalid names
authorSean Barag <redacted>
Thu, 1 Oct 2020 03:46:12 +0000 (03:46 +0000)
committerJunio C Hamano <redacted>
Thu, 1 Oct 2020 05:09:13 +0000 (22:09 -0700)
In preparation for a future patch that moves `builtin/remote.c`'s
remote-name validation, ensure `git remote add` and `git remote rename`
report errors when the new name isn't valid.

Signed-off-by: Sean Barag <redacted>
Signed-off-by: Junio C Hamano <redacted>
t/t5505-remote.sh

index 8d62edd98b5c87995f5f0697b4b7198c6da58c0d..1156f520694fba0d74d46b6351065547b1a66679 100755 (executable)
@@ -179,6 +179,13 @@ test_expect_success 'rename errors out early when deleting non-existent branch'
        )
 '
 
+test_expect_success 'rename errors out early when when new name is invalid' '
+       test_config remote.foo.vcs bar &&
+       echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
+       test_must_fail git remote rename foo invalid...name 2>actual &&
+       test_i18ncmp expect actual
+'
+
 test_expect_success 'add existing foreign_vcs remote' '
        test_config remote.foo.vcs bar &&
        echo "fatal: remote foo already exists." >expect &&
@@ -194,6 +201,12 @@ test_expect_success 'add existing foreign_vcs remote' '
        test_i18ncmp expect actual
 '
 
+test_expect_success 'add invalid foreign_vcs remote' '
+       echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
+       test_must_fail git remote add invalid...name bar 2>actual &&
+       test_i18ncmp expect actual
+'
+
 cat >test/expect <<EOF
 * remote origin
   Fetch URL: $(pwd)/one
git clone https://git.99rst.org/PROJECT