Skip to content

Commit 3d77fbb

Browse files
rybakgitster
authored andcommitted
t1300: add tests for missing keys
There are several tests in t1300-config.sh that validate failing invocations of "git config". However, there are no tests that check what happens when "git config" is asked to retrieve a value for a missing key. Add tests that check this for various combinations of "<section>.<key>" and "<section>.<subsection>.<key>". Signed-off-by: Andrei Rybak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 93f8604 commit 3d77fbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

t/t1300-config.sh

Lines changed: 17 additions & 0 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

0 commit comments

Comments
 (0)