cat-file tests: move bogus_* variable declarations earlier
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>
Ævar Arnfjörð Bjarmason committed
Oct 1, 2021 at 11:16 UTC
70e4a57762e7a23af8772483026b1e00f9de296b
1 file changed
+19
-16
t/t1006-cat-file.sh
+19
-16
@@ -315,36 +315,39 @@ test_expect_success '%(deltabase) reports packed delta bases' '
315
}
316
'
317
318
-bogus_type="bogus"
319
-bogus_content="bogus"
320
-bogus_size=$(strlen "$bogus_content")
321
-bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
318
+test_expect_success 'setup bogus data' '
319
+ bogus_short_type="bogus" &&
320
+ bogus_short_content="bogus" &&
321
+ bogus_short_size=$(strlen "$bogus_short_content") &&
322
+ bogus_short_sha1=$(echo_without_newline "$bogus_short_content" | git hash-object -t $bogus_short_type --literally -w --stdin) &&
323
+
324
+ bogus_long_type="abcdefghijklmnopqrstuvwxyz1234679" &&
325
+ bogus_long_content="bogus" &&
326
+ bogus_long_size=$(strlen "$bogus_long_content") &&
327
+ bogus_long_sha1=$(echo_without_newline "$bogus_long_content" | git hash-object -t $bogus_long_type --literally -w --stdin)
328
+'
329
330
test_expect_success "Type of broken object is correct" '
324
- echo $bogus_type >expect &&
325
- git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
331
+ echo $bogus_short_type >expect &&
332
+ git cat-file -t --allow-unknown-type $bogus_short_sha1 >actual &&
333
test_cmp expect actual
334
'
335
336
test_expect_success "Size of broken object is correct" '
330
- echo $bogus_size >expect &&
331
- git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
337
+ echo $bogus_short_size >expect &&
338
+ git cat-file -s --allow-unknown-type $bogus_short_sha1 >actual &&
339
test_cmp expect actual
340
'
334
-bogus_type="abcdefghijklmnopqrstuvwxyz1234679"
335
-bogus_content="bogus"
336
-bogus_size=$(strlen "$bogus_content")
337
-bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
341
342
test_expect_success "Type of broken object is correct when type is large" '
340
- echo $bogus_type >expect &&
341
- git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
343
+ echo $bogus_long_type >expect &&
344
+ git cat-file -t --allow-unknown-type $bogus_long_sha1 >actual &&
345
test_cmp expect actual
346
'
347
348
test_expect_success "Size of large broken object is correct when type is large" '
346
- echo $bogus_size >expect &&
347
- git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
349
+ echo $bogus_long_size >expect &&
350
+ git cat-file -s --allow-unknown-type $bogus_long_sha1 >actual &&
351
test_cmp expect actual
352
'
353