[PATCH v2 01/10] cat-file tests: test for bogus type name handling
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 20, 2021, 12:50 UTC
- Message-ID
- <patch-01.10-5818eca45d-20210420T124428Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.10-0000000000-20210420T124428Z-avarab@gmail.com>
Add a test of how "cat-file" behaves when given a bogus type in its "git cat-file <TYPE> <OBJECT>" mode. There were existing tests (just below this one) for "-t bogus" or "--allow-unknown-type" modes, but none for the switch-less mode.
This test is similar to the one that exists for "git hash-object" already, see b7994af0f92 (type_from_string_gently: make sure length matches, 2015-04-17).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- t/t1006-cat-file.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 5d2dc99b74..908797dcae 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -315,6 +315,22 @@ test_expect_success '%(deltabase) reports packed delta bases' ' } ' +test_expect_success 'cat-file complains about bogus type name' ' + test_must_fail git cat-file co HEAD >out 2>err && + test_must_be_empty out && + cat >expected <<-\EOF && + fatal: invalid object type "co" + EOF + test_cmp expected err && + + test_must_fail git cat-file bogus HEAD >out 2>err && + test_must_be_empty out && + cat >expected <<-\EOF && + fatal: invalid object type "bogus" + EOF + test_cmp expected err +' + bogus_type="bogus" bogus_content="bogus" bogus_size=$(strlen "$bogus_content")
-- 2.31.1.723.ga5d7868e4a