t1007: remove SHA1 prerequisites
Update this test to use test_oid_cache to specify the object IDs for both SHA-1 and SHA-256. Since this test now works with both algorithms, remove the SHA1 prerequisite. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jun 28, 2019 at 22:59 UTC
2e306f6c4f7408432ae1bed5e1f9978fe52b11df
1 file changed
+32
-26
t/t1007-hash-object.sh
+32
-26
@@ -9,22 +9,19 @@ echo_without_newline() {
9
}
10
11
test_blob_does_not_exist() {
12
- test_expect_success SHA1 'blob does not exist in database' "
12
+ test_expect_success 'blob does not exist in database' "
13
test_must_fail git cat-file blob $1
14
"
15
}
16
17
test_blob_exists() {
18
- test_expect_success SHA1 'blob exists in database' "
18
+ test_expect_success 'blob exists in database' "
19
git cat-file blob $1
20
"
21
}
22
23
hello_content="Hello World"
24
-hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
25
-
24
example_content="This is an example"
27
-example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399
25
26
setup_repo() {
27
echo_without_newline "$hello_content" > hello
@@ -44,7 +41,16 @@ pop_repo() {
41
rm -rf $test_repo
42
}
43
47
-setup_repo
44
+test_expect_success 'setup' '
45
+ setup_repo &&
46
+ test_oid_cache <<-EOF
47
+ hello sha1:5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
48
+ hello sha256:1e3b6c04d2eeb2b3e45c8a330445404c0b7cc7b257e2b097167d26f5230090c4
49
+
50
+ example sha1:ddd3f836d3e3fbb7ae289aa9ae83536f76956399
51
+ example sha256:b44fe1fe65589848253737db859bd490453510719d7424daab03daf0767b85ae
52
+ EOF
53
+'
54
55
# Argument checking
56
@@ -73,23 +79,23 @@ test_expect_success "Can't use --path with --no-filters" '
79
80
push_repo
81
76
-test_expect_success SHA1 'hash a file' '
77
- test $hello_sha1 = $(git hash-object hello)
82
+test_expect_success 'hash a file' '
83
+ test "$(test_oid hello)" = $(git hash-object hello)
84
'
85
80
-test_blob_does_not_exist $hello_sha1
86
+test_blob_does_not_exist "$(test_oid hello)"
87
82
-test_expect_success SHA1 'hash from stdin' '
83
- test $example_sha1 = $(git hash-object --stdin < example)
88
+test_expect_success 'hash from stdin' '
89
+ test "$(test_oid example)" = $(git hash-object --stdin < example)
90
'
91
86
-test_blob_does_not_exist $example_sha1
92
+test_blob_does_not_exist "$(test_oid example)"
93
88
-test_expect_success SHA1 'hash a file and write to database' '
89
- test $hello_sha1 = $(git hash-object -w hello)
94
+test_expect_success 'hash a file and write to database' '
95
+ test "$(test_oid hello)" = $(git hash-object -w hello)
96
'
97
92
-test_blob_exists $hello_sha1
98
+test_blob_exists "$(test_oid hello)"
99
100
test_expect_success 'git hash-object --stdin file1 <file0 first operates on file0, then file1' '
101
echo foo > file1 &&
@@ -161,11 +167,11 @@ pop_repo
167
for args in "-w --stdin" "--stdin -w"; do
168
push_repo
169
164
- test_expect_success SHA1 "hash from stdin and write to database ($args)" '
165
- test $example_sha1 = $(git hash-object $args < example)
170
+ test_expect_success "hash from stdin and write to database ($args)" '
171
+ test "$(test_oid example)" = $(git hash-object $args < example)
172
'
173
168
- test_blob_exists $example_sha1
174
+ test_blob_exists "$(test_oid example)"
175
176
pop_repo
177
done
@@ -173,22 +179,22 @@ done
179
filenames="hello
180
example"
181
176
-sha1s="$hello_sha1
177
-$example_sha1"
182
+oids="$(test_oid hello)
183
+$(test_oid example)"
184
179
-test_expect_success SHA1 "hash two files with names on stdin" '
180
- test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
185
+test_expect_success "hash two files with names on stdin" '
186
+ test "$oids" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
187
'
188
189
for args in "-w --stdin-paths" "--stdin-paths -w"; do
190
push_repo
191
186
- test_expect_success SHA1 "hash two files with names on stdin and write to database ($args)" '
187
- test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object $args)"
192
+ test_expect_success "hash two files with names on stdin and write to database ($args)" '
193
+ test "$oids" = "$(echo_without_newline "$filenames" | git hash-object $args)"
194
'
195
190
- test_blob_exists $hello_sha1
191
- test_blob_exists $example_sha1
196
+ test_blob_exists "$(test_oid hello)"
197
+ test_blob_exists "$(test_oid example)"
198
199
pop_repo
200
done