diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-05-15 23:59:04 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-05-15 23:59:04 +0300 |
commit | 2bb14fbf2f45e2ec30ac4a63b994c51596f0d8ff (patch) | |
tree | 0b645a01e1f5a153c1e0817f565b211ed2beb6ac /t/t1300-config.sh | |
parent | 66077a29e18d6e3918982a00bd91cedbf1986ae2 (diff) | |
parent | 3d77fbb664acab5157617cdb368a0c657bf20919 (diff) |
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
Diffstat (limited to 't/t1300-config.sh')
-rwxr-xr-x | t/t1300-config.sh | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 34d30f3bc6..86bfbc2b36 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -98,6 +98,23 @@ test_expect_success 'subsections are not canonicalized by git-config' ' test_cmp_config two section.SubSection.key ' +test_missing_key () { + local key="$1" && + local title="$2" && + test_expect_success "value for $title is not printed" ' + test_must_fail git config "$key" >out 2>err && + test_must_be_empty out && + test_must_be_empty err + ' +} + +test_missing_key 'missingsection.missingkey' 'missing section and missing key' +test_missing_key 'missingsection.penguin' 'missing section and existing key' +test_missing_key 'section.missingkey' 'existing section and missing key' +test_missing_key 'section.MissingSubSection.missingkey' 'missing subsection and missing key' +test_missing_key 'section.SubSection.missingkey' 'existing subsection and missing key' +test_missing_key 'section.MissingSubSection.key' 'missing subsection and existing key' + cat > .git/config <<\EOF [alpha] bar = foo @@ -1488,35 +1505,29 @@ test_expect_success 'git config ignores pairs without count' ' test_must_be_empty error ' -test_expect_success 'git config ignores pairs with zero count' ' - test_must_fail env \ - GIT_CONFIG_COUNT=0 \ - GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ - git config pair.one -' - test_expect_success 'git config ignores pairs exceeding count' ' GIT_CONFIG_COUNT=1 \ GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \ - git config --get-regexp "pair.*" >actual && + git config --get-regexp "pair.*" >actual 2>error && cat >expect <<-EOF && pair.one value EOF - test_cmp expect actual + test_cmp expect actual && + test_must_be_empty error ' test_expect_success 'git config ignores pairs with zero count' ' test_must_fail env \ GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ - git config pair.one >error && + git config pair.one 2>error && test_must_be_empty error ' test_expect_success 'git config ignores pairs with empty count' ' test_must_fail env \ GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \ - git config pair.one >error && + git config pair.one 2>error && test_must_be_empty error ' |