MCPcopy
hub / github.com/perkeep/perkeep / streamAll

Function streamAll

pkg/blobserver/diskpacked/stream_test.go:136–153  ·  view source on GitHub ↗

It verifies the size and hash of each before returning and fails the test if any of the checks fail. It also fails the test if StreamBlobs returns a non-nil error.

(t *testing.T, s *storage)

Source from the content-addressed store, hash-verified

134// before returning and fails the test if any of the checks fail. It
135// also fails the test if StreamBlobs returns a non-nil error.
136func streamAll(t *testing.T, s *storage) []*blob.Blob {
137 blobs := make([]*blob.Blob, 0, 1024)
138 ch := make(chan blobserver.BlobAndToken)
139 errCh := make(chan error, 1)
140
141 ctx, cancel := context.WithCancel(context.Background())
142 defer cancel()
143 go func() { errCh <- s.StreamBlobs(ctx, ch, "") }()
144
145 for bt := range ch {
146 verifySizeAndHash(t, bt.Blob)
147 blobs = append(blobs, bt.Blob)
148 }
149 if err := <-errCh; err != nil {
150 t.Fatalf("StreamBlobs error = %v", err)
151 }
152 return blobs
153}
154
155// Tests the streaming of all blobs in a storage, with hash verification.
156func TestBasicStreaming(t *testing.T) {

Callers 1

TestBasicStreamingFunction · 0.85

Calls 3

verifySizeAndHashFunction · 0.85
StreamBlobsMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected