]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cat-file tests: move bogus_* variable declarations earlier
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Oct 2021 09:16:41 +0000 (11:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 22:05:59 +0000 (15:05 -0700)
Change the short/long bogus bogus object type variables into a form
where the two sets can be used concurrently. This'll be used by
subsequently added tests.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1006-cat-file.sh

index 5d2dc99b74ad005e00ae76c1c6616100238e414e..2fe8295182f6611930d6e761e22aa7fb05a04ccd 100755 (executable)
@@ -315,36 +315,39 @@ test_expect_success '%(deltabase) reports packed delta bases' '
        }
 '
 
-bogus_type="bogus"
-bogus_content="bogus"
-bogus_size=$(strlen "$bogus_content")
-bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
+test_expect_success 'setup bogus data' '
+       bogus_short_type="bogus" &&
+       bogus_short_content="bogus" &&
+       bogus_short_size=$(strlen "$bogus_short_content") &&
+       bogus_short_sha1=$(echo_without_newline "$bogus_short_content" | git hash-object -t $bogus_short_type --literally -w --stdin) &&
+
+       bogus_long_type="abcdefghijklmnopqrstuvwxyz1234679" &&
+       bogus_long_content="bogus" &&
+       bogus_long_size=$(strlen "$bogus_long_content") &&
+       bogus_long_sha1=$(echo_without_newline "$bogus_long_content" | git hash-object -t $bogus_long_type --literally -w --stdin)
+'
 
 test_expect_success "Type of broken object is correct" '
-       echo $bogus_type >expect &&
-       git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
+       echo $bogus_short_type >expect &&
+       git cat-file -t --allow-unknown-type $bogus_short_sha1 >actual &&
        test_cmp expect actual
 '
 
 test_expect_success "Size of broken object is correct" '
-       echo $bogus_size >expect &&
-       git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
+       echo $bogus_short_size >expect &&
+       git cat-file -s --allow-unknown-type $bogus_short_sha1 >actual &&
        test_cmp expect actual
 '
-bogus_type="abcdefghijklmnopqrstuvwxyz1234679"
-bogus_content="bogus"
-bogus_size=$(strlen "$bogus_content")
-bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
 
 test_expect_success "Type of broken object is correct when type is large" '
-       echo $bogus_type >expect &&
-       git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
+       echo $bogus_long_type >expect &&
+       git cat-file -t --allow-unknown-type $bogus_long_sha1 >actual &&
        test_cmp expect actual
 '
 
 test_expect_success "Size of large broken object is correct when type is large" '
-       echo $bogus_size >expect &&
-       git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
+       echo $bogus_long_size >expect &&
+       git cat-file -s --allow-unknown-type $bogus_long_sha1 >actual &&
        test_cmp expect actual
 '