MCPcopy
hub / github.com/perkeep/perkeep / verifySizeAndHash

Function verifySizeAndHash

pkg/blobserver/diskpacked/stream_test.go:173–191  ·  view source on GitHub ↗
(t *testing.T, blob *blob.Blob)

Source from the content-addressed store, hash-verified

171}
172
173func verifySizeAndHash(t *testing.T, blob *blob.Blob) {
174 hash := sha1.New()
175 r, err := blob.ReadAll(ctxbg)
176 if err != nil {
177 t.Fatal(err)
178 }
179 n, err := io.Copy(hash, r)
180 if err != nil {
181 t.Fatal(err)
182 }
183
184 if uint32(n) != blob.Size() {
185 t.Fatalf("read %d bytes from blob %v; want %v", n, blob.Ref(), blob.Size())
186 }
187
188 if !blob.SizedRef().HashMatches(hash) {
189 t.Fatalf("read wrong bytes from blobref %v (digest mismatch)", blob.Ref())
190 }
191}
192
193// Tests that we can correctly switch over to the next pack if we
194// still need to stream more blobs when a pack reaches EOF.

Callers 1

streamAllFunction · 0.85

Calls 7

RefStruct · 0.92
SizedRefStruct · 0.92
ReadAllMethod · 0.80
FatalMethod · 0.80
SizeMethod · 0.65
FatalfMethod · 0.65
HashMatchesMethod · 0.45

Tested by

no test coverage detected