Skip to content

Commit 258902c

Browse files
avargitster
authored andcommitted
config tests: cover blind spots in git_die_config() tests
There were no tests checking for the output of the git_die_config() function in the config API, added in 5a80e97 (config: add `git_die_config()` to the config-set API, 2014-08-07). We only tested "test_must_fail", but didn't assert the output. We need tests for this because a subsequent commit will alter the return value of git_config_get_value_multi(), which is used to get the config values in the git_die_config() function. This test coverage helps to build confidence in that subsequent change. These tests cover different interactions with git_die_config(): - The "notes.mergeStrategy" test in "t/t3309-notes-merge-auto-resolve.sh" is a case where a function outside of config.c (git_config_get_notes_strategy()) calls git_die_config(). - The "gc.pruneExpire" test in "t5304-prune.sh" is a case where git_config_get_expiry() calls git_die_config(), covering a different "type" than the "string" test for "notes.mergeStrategy". - The "fetch.negotiationAlgorithm" test in "t/t5552-skipping-fetch-negotiator.sh" is a case where git_config_get_string*() calls git_die_config(). We also cover both the "from command-line config" and "in file..at line" cases here. The clobbering of existing ".git/config" files here is so that we're not implicitly testing the line count of the default config. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c000d91 commit 258902c

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

t/t3309-notes-merge-auto-resolve.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,12 @@ test_expect_success 'merge z into y with invalid strategy => Fail/No changes' '
360360

361361
test_expect_success 'merge z into y with invalid configuration option => Fail/No changes' '
362362
git config core.notesRef refs/notes/y &&
363-
test_must_fail git -c notes.mergeStrategy="foo" notes merge z &&
363+
cat >expect <<-\EOF &&
364+
error: unknown notes merge strategy foo
365+
fatal: unable to parse '\''notes.mergeStrategy'\'' from command-line config
366+
EOF
367+
test_must_fail git -c notes.mergeStrategy="foo" notes merge z 2>actual &&
368+
test_cmp expect actual &&
364369
# Verify no changes (y)
365370
verify_notes y y
366371
'

t/t5304-prune.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ test_expect_success 'gc: implicit prune --expire' '
6464
'
6565

6666
test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' '
67-
git config gc.pruneExpire invalid &&
68-
test_must_fail git gc
67+
test_when_finished "rm -rf repo" &&
68+
git init repo &&
69+
>repo/.git/config &&
70+
git -C repo config gc.pruneExpire invalid &&
71+
cat >expect <<-\EOF &&
72+
error: Invalid gc.pruneexpire: '\''invalid'\''
73+
fatal: bad config variable '\''gc.pruneexpire'\'' in file '\''.git/config'\'' at line 2
74+
EOF
75+
test_must_fail git -C repo gc 2>actual &&
76+
test_cmp expect actual
6977
'
7078

7179
test_expect_success 'gc: start with ok gc.pruneExpire' '

t/t5552-skipping-fetch-negotiator.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
test_description='test skipping fetch negotiator'
44
. ./test-lib.sh
55

6+
test_expect_success 'fetch.negotiationalgorithm config' '
7+
test_when_finished "rm -rf repo" &&
8+
git init repo &&
9+
cat >repo/.git/config <<-\EOF &&
10+
[fetch]
11+
negotiationAlgorithm
12+
EOF
13+
cat >expect <<-\EOF &&
14+
error: missing value for '\''fetch.negotiationalgorithm'\''
15+
fatal: bad config variable '\''fetch.negotiationalgorithm'\'' in file '\''.git/config'\'' at line 2
16+
EOF
17+
test_expect_code 128 git -C repo fetch >out 2>actual &&
18+
test_must_be_empty out &&
19+
test_cmp expect actual
20+
'
21+
622
have_sent () {
723
while test "$#" -ne 0
824
do

0 commit comments

Comments
 (0)