Skip to content

Commit 2bb14fb

Browse files
committed
Merge branch 'ar/config-count-tests-updates'
Test updates. * ar/config-count-tests-updates: t1300: add tests for missing keys t1300: check stderr for "ignores pairs" tests t1300: drop duplicate test
2 parents 66077a2 + 3d77fbb commit 2bb14fb

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

t/t1300-config.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ test_expect_success 'subsections are not canonicalized by git-config' '
9898
test_cmp_config two section.SubSection.key
9999
'
100100

101+
test_missing_key () {
102+
local key="$1" &&
103+
local title="$2" &&
104+
test_expect_success "value for $title is not printed" '
105+
test_must_fail git config "$key" >out 2>err &&
106+
test_must_be_empty out &&
107+
test_must_be_empty err
108+
'
109+
}
110+
111+
test_missing_key 'missingsection.missingkey' 'missing section and missing key'
112+
test_missing_key 'missingsection.penguin' 'missing section and existing key'
113+
test_missing_key 'section.missingkey' 'existing section and missing key'
114+
test_missing_key 'section.MissingSubSection.missingkey' 'missing subsection and missing key'
115+
test_missing_key 'section.SubSection.missingkey' 'existing subsection and missing key'
116+
test_missing_key 'section.MissingSubSection.key' 'missing subsection and existing key'
117+
101118
cat > .git/config <<\EOF
102119
[alpha]
103120
bar = foo
@@ -1488,35 +1505,29 @@ test_expect_success 'git config ignores pairs without count' '
14881505
test_must_be_empty error
14891506
'
14901507

1491-
test_expect_success 'git config ignores pairs with zero count' '
1492-
test_must_fail env \
1493-
GIT_CONFIG_COUNT=0 \
1494-
GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1495-
git config pair.one
1496-
'
1497-
14981508
test_expect_success 'git config ignores pairs exceeding count' '
14991509
GIT_CONFIG_COUNT=1 \
15001510
GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
15011511
GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
1502-
git config --get-regexp "pair.*" >actual &&
1512+
git config --get-regexp "pair.*" >actual 2>error &&
15031513
cat >expect <<-EOF &&
15041514
pair.one value
15051515
EOF
1506-
test_cmp expect actual
1516+
test_cmp expect actual &&
1517+
test_must_be_empty error
15071518
'
15081519

15091520
test_expect_success 'git config ignores pairs with zero count' '
15101521
test_must_fail env \
15111522
GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1512-
git config pair.one >error &&
1523+
git config pair.one 2>error &&
15131524
test_must_be_empty error
15141525
'
15151526

15161527
test_expect_success 'git config ignores pairs with empty count' '
15171528
test_must_fail env \
15181529
GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1519-
git config pair.one >error &&
1530+
git config pair.one 2>error &&
15201531
test_must_be_empty error
15211532
'
15221533

0 commit comments

Comments
 (0)