예제 #1
0
func TestStaticStreamer(t *testing.T) {
	var blobs []*blob.Blob
	var want []blob.SizedRef
	for i := 0; i < 5; i++ {
		tb := &test.Blob{strconv.Itoa(i)}
		b := tb.Blob()
		blobs = append(blobs, b)
		want = append(want, b.SizedRef())
	}
	bs := staticStreamer(blobs)
	storagetest.TestStreamer(t, bs, storagetest.WantSizedRefs(want))
}
예제 #2
0
// Tests the streaming of all blobs in a storage, with hash verification.
func TestBasicStreaming(t *testing.T) {
	s, clean := newTestStorage(t, pack{testPack1})
	defer clean()

	expected := len(testPack1)
	blobs := streamAll(t, s)
	if len(blobs) != expected {
		t.Fatalf("Wrong blob count: Expected %d, got %d", expected,
			len(blobs))
	}
	wantRefs := make([]blob.SizedRef, len(blobs))
	for i, b := range blobs {
		wantRefs[i] = b.SizedRef()
	}
	storagetest.TestStreamer(t, s, storagetest.WantSizedRefs(wantRefs))
}
예제 #3
0
func TestMultiStreamer(t *testing.T) {
	var streamers []blobserver.BlobStreamer
	var want []blob.SizedRef
	n := 0

	for st := 0; st < 3; st++ {
		var blobs []*blob.Blob
		for i := 0; i < 3; i++ {
			n++
			tb := &test.Blob{strconv.Itoa(n)}
			b := tb.Blob()
			want = append(want, b.SizedRef()) // overall
			blobs = append(blobs, b)          // this sub-streamer
		}
		streamers = append(streamers, staticStreamer(blobs))
	}
	storagetest.TestStreamer(t, blobserver.NewMultiBlobStreamer(streamers...), storagetest.WantSizedRefs(want))
}