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

Function TestBlockMetaObjectAdded

tempodb/backend/block_meta_test.go:32–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestBlockMetaObjectAdded(t *testing.T) {
33 now := time.Unix(time.Now().Unix(), 0)
34
35 tests := []struct {
36 ids [][]byte
37 starts []uint32
38 ends []uint32
39 expectedStart time.Time
40 expectedEnd time.Time
41 expectedObjects int64
42 }{
43 {},
44 {
45 ids: [][]byte{
46 {0x01},
47 },
48 starts: []uint32{
49 uint32(now.Unix()),
50 },
51 ends: []uint32{
52 uint32(now.Add(time.Minute).Unix()),
53 },
54 expectedStart: now,
55 expectedEnd: now.Add(time.Minute),
56 expectedObjects: 1,
57 },
58 {
59 ids: [][]byte{
60 {0x01},
61 {0x02},
62 },
63 starts: []uint32{
64 uint32(now.Unix()),
65 uint32(now.Add(-time.Minute).Unix()),
66 },
67 ends: []uint32{
68 uint32(now.Add(time.Hour).Unix()),
69 uint32(now.Add(time.Minute).Unix()),
70 },
71 expectedStart: now.Add(-time.Minute),
72 expectedEnd: now.Add(time.Hour),
73 expectedObjects: 2,
74 },
75 }
76
77 for _, tc := range tests {
78 b := &BlockMeta{}
79
80 for i := 0; i < len(tc.ids); i++ {
81 b.ObjectAdded(tc.starts[i], tc.ends[i])
82 }
83
84 assert.Equal(t, tc.expectedStart, b.StartTime)
85 assert.Equal(t, tc.expectedEnd, b.EndTime)
86 assert.Equal(t, tc.expectedObjects, b.TotalObjects)
87 }
88}
89

Callers

nothing calls this directly

Calls 4

ObjectAddedMethod · 0.95
NowMethod · 0.65
AddMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected