Skip to content

Commit 70e4a57

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5ed333 commit 70e4a57

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

t/t1006-cat-file.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,36 +315,39 @@ test_expect_success '%(deltabase) reports packed delta bases' '
315315
}
316316
'
317317

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+
'
322329

323330
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 &&
326333
test_cmp expect actual
327334
'
328335

329336
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 &&
332339
test_cmp expect actual
333340
'
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)
338341

339342
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 &&
342345
test_cmp expect actual
343346
'
344347

345348
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 &&
348351
test_cmp expect actual
349352
'
350353

0 commit comments

Comments
 (0)