remote: add tests for add and rename with invalid names
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 <sean@barag.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sean Barag committed
Oct 1, 2020 at 03:46 UTC
444825c7c1148c0a38708238467c33ba370c58b2
1 file changed
+13
t/t5505-remote.sh
+13
@@ -179,6 +179,13 @@ test_expect_success 'rename errors out early when deleting non-existent branch'
179
)
180
'
181
182
+test_expect_success 'rename errors out early when when new name is invalid' '
183
+ test_config remote.foo.vcs bar &&
184
+ echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
185
+ test_must_fail git remote rename foo invalid...name 2>actual &&
186
+ test_i18ncmp expect actual
187
+'
188
+
189
test_expect_success 'add existing foreign_vcs remote' '
190
test_config remote.foo.vcs bar &&
191
echo "fatal: remote foo already exists." >expect &&
@@ -194,6 +201,12 @@ test_expect_success 'add existing foreign_vcs remote' '
201
test_i18ncmp expect actual
202
'
203
204
+test_expect_success 'add invalid foreign_vcs remote' '
205
+ echo "fatal: '\''invalid...name'\'' is not a valid remote name" >expect &&
206
+ test_must_fail git remote add invalid...name bar 2>actual &&
207
+ test_i18ncmp expect actual
208
+'
209
+
210
cat >test/expect <<EOF
211
* remote origin
212
Fetch URL: $(pwd)/one