completion: add a test for __git_remotes() helper function

The test checks that both remotes under '$GIT_DIR/remotes' and remotes in the config file are listed. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Mar 4, 2015 at 15:10 UTC 2acc194075e936de147f3cb01e02ef39e064cc3c
1 file changed +19
t/t9902-completion.sh
+19
@@ -351,6 +351,25 @@ test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name
351 __gitcomp_nl "$invalid_variable_name"
352 '
353
354 +test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' '
355 + cat >expect <<-EOF &&
356 + remote_from_file_1
357 + remote_from_file_2
358 + remote_in_config_1
359 + remote_in_config_2
360 + EOF
361 + test_when_finished "rm -rf .git/remotes" &&
362 + mkdir -p .git/remotes &&
363 + >.git/remotes/remote_from_file_1 &&
364 + >.git/remotes/remote_from_file_2 &&
365 + test_when_finished "git remote remove remote_in_config_1" &&
366 + git remote add remote_in_config_1 git://remote_1 &&
367 + test_when_finished "git remote remove remote_in_config_2" &&
368 + git remote add remote_in_config_2 git://remote_2 &&
369 + __git_remotes >actual &&
370 + test_cmp expect actual
371 +'
372 +
373 test_expect_success 'basic' '
374 run_completion "git " &&
375 # built-in