MCPcopy
hub / github.com/grafana/tempo / testIterator

Function testIterator

tempodb/wal/wal_test.go:177–210  ·  view source on GitHub ↗
(t *testing.T, e encoding.VersionedEncoding)

Source from the content-addressed store, hash-verified

175}
176
177func testIterator(t *testing.T, e encoding.VersionedEncoding) {
178 runWALTest(t, e.Version(), func(ids [][]byte, objs []*tempopb.Trace, block common.WALBlock) {
179 ctx := context.Background()
180
181 iterator, err := block.Iterator(ctx)
182 require.NoError(t, err)
183 defer iterator.Close()
184
185 i := 0
186 for {
187 id, obj, err := iterator.Next(ctx)
188 if errors.Is(err, io.EOF) || id == nil {
189 break
190 }
191 require.NoError(t, err)
192
193 found := false
194 j := 0
195 for ; j < len(ids); j++ {
196 if bytes.Equal(ids[j], id) {
197 found = true
198 break
199 }
200 }
201
202 require.True(t, found)
203 require.Equal(t, objs[j], obj)
204 require.Equal(t, ids[j], []byte(id))
205 i++
206 }
207
208 require.Equal(t, len(objs), i)
209 })
210}
211
212func TestSearch(t *testing.T) {
213 for _, e := range encoding.AllEncodingsForWrites() {

Callers 1

TestIteratorFunction · 0.70

Calls 6

runWALTestFunction · 0.85
VersionMethod · 0.65
IteratorMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected