(t *testing.T)
| 36 | } |
| 37 | |
| 38 | func TestIterateAllPrefixesInParallel(t *testing.T) { |
| 39 | data := blobtesting.DataMap{} |
| 40 | st := blobtesting.NewMapStorage(data, nil, nil) |
| 41 | ctx := context.Background() |
| 42 | st.PutBlob(ctx, "foo", gather.FromSlice([]byte{1, 2, 3}), blob.PutOptions{}) |
| 43 | st.PutBlob(ctx, "boo", gather.FromSlice([]byte{2, 3, 4}), blob.PutOptions{}) |
| 44 | st.PutBlob(ctx, "bar", gather.FromSlice([]byte{3, 4, 5}), blob.PutOptions{}) |
| 45 | |
| 46 | var ( |
| 47 | mu sync.Mutex |
| 48 | got []blob.ID |
| 49 | ) |
| 50 | |
| 51 | require.NoError(t, blob.IterateAllPrefixesInParallel(ctx, 10, st, []blob.ID{ |
| 52 | "b", |
| 53 | "c", |
| 54 | }, func(m blob.Metadata) error { |
| 55 | mu.Lock() |
| 56 | defer mu.Unlock() |
| 57 | |
| 58 | got = append(got, m.BlobID) |
| 59 | |
| 60 | return nil |
| 61 | })) |
| 62 | |
| 63 | require.ElementsMatch(t, []blob.ID{"boo", "bar"}, got) |
| 64 | |
| 65 | got = nil |
| 66 | |
| 67 | require.NoError(t, blob.IterateAllPrefixesInParallel(ctx, 0, st, []blob.ID{ |
| 68 | "f", |
| 69 | }, func(m blob.Metadata) error { |
| 70 | mu.Lock() |
| 71 | defer mu.Unlock() |
| 72 | |
| 73 | got = append(got, m.BlobID) |
| 74 | |
| 75 | return nil |
| 76 | })) |
| 77 | |
| 78 | require.ElementsMatch(t, []blob.ID{"foo"}, got) |
| 79 | |
| 80 | got = nil |
| 81 | |
| 82 | require.NoError(t, blob.IterateAllPrefixesInParallel(ctx, 0, st, []blob.ID{ |
| 83 | "f", |
| 84 | "b", |
| 85 | }, func(m blob.Metadata) error { |
| 86 | mu.Lock() |
| 87 | defer mu.Unlock() |
| 88 | |
| 89 | got = append(got, m.BlobID) |
| 90 | |
| 91 | return nil |
| 92 | })) |
| 93 | |
| 94 | require.ElementsMatch(t, []blob.ID{"foo", "bar", "boo"}, got) |
| 95 |
nothing calls this directly
no test coverage detected