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

Function TestDedicatedColumnsFromTempopb

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

Source from the content-addressed store, hash-verified

219}
220
221func TestDedicatedColumnsFromTempopb(t *testing.T) {
222 tests := []struct {
223 name string
224 cols []*tempopb.DedicatedColumn
225 expected DedicatedColumns
226 expectedErr error
227 }{
228 {
229 name: "no error",
230 cols: []*tempopb.DedicatedColumn{
231 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.1", Type: tempopb.DedicatedColumn_STRING},
232 {Scope: tempopb.DedicatedColumn_RESOURCE, Name: "test.res.1", Type: tempopb.DedicatedColumn_STRING},
233 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.2", Type: tempopb.DedicatedColumn_STRING},
234 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.3", Type: tempopb.DedicatedColumn_INT},
235 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.4", Type: tempopb.DedicatedColumn_INT, Options: tempopb.DedicatedColumn_ARRAY},
236 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.5", Type: tempopb.DedicatedColumn_STRING, Options: tempopb.DedicatedColumn_BLOB | tempopb.DedicatedColumn_ARRAY},
237 },
238 expected: DedicatedColumns{
239 {Scope: DedicatedColumnScopeSpan, Name: "test.span.1", Type: DedicatedColumnTypeString},
240 {Scope: DedicatedColumnScopeResource, Name: "test.res.1", Type: DedicatedColumnTypeString},
241 {Scope: DedicatedColumnScopeSpan, Name: "test.span.2", Type: DedicatedColumnTypeString},
242 {Scope: DedicatedColumnScopeSpan, Name: "test.span.3", Type: DedicatedColumnTypeInt},
243 {Scope: DedicatedColumnScopeSpan, Name: "test.span.4", Type: DedicatedColumnTypeInt, Options: DedicatedColumnOptions{DedicatedColumnOptionArray}},
244 {Scope: DedicatedColumnScopeSpan, Name: "test.span.5", Type: DedicatedColumnTypeString, Options: DedicatedColumnOptions{DedicatedColumnOptionArray, DedicatedColumnOptionBlob}},
245 },
246 },
247 {
248 name: "wrong type",
249 cols: []*tempopb.DedicatedColumn{
250 {Scope: tempopb.DedicatedColumn_RESOURCE, Name: "test.res.1", Type: tempopb.DedicatedColumn_Type(3)},
251 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.2", Type: tempopb.DedicatedColumn_STRING},
252 },
253 expectedErr: errors.New("unable to convert dedicated column 'test.res.1': invalid value for tempopb.DedicatedColumn_Type '3'"),
254 },
255 {
256 name: "wrong scope",
257 cols: []*tempopb.DedicatedColumn{
258 {Scope: tempopb.DedicatedColumn_RESOURCE, Name: "test.res.1", Type: tempopb.DedicatedColumn_STRING},
259 {Scope: tempopb.DedicatedColumn_Scope(4), Name: "test.span.2", Type: tempopb.DedicatedColumn_STRING},
260 },
261 expectedErr: errors.New("unable to convert dedicated column 'test.span.2': invalid value for tempopb.DedicatedColumn_Scope '4'"),
262 },
263 }
264
265 for _, tc := range tests {
266 t.Run(tc.name, func(t *testing.T) {
267 cols, err := DedicatedColumnsFromTempopb(tc.cols)
268 if tc.expectedErr != nil {
269 require.Error(t, err)
270 assert.EqualError(t, err, tc.expectedErr.Error())
271 } else {
272 require.NoError(t, err)
273 assert.Equal(t, tc.expected, cols)
274 }
275 })
276 }
277}
278

Callers

nothing calls this directly

Calls 6

DedicatedColumn_TypeTypeAlias · 0.92
DedicatedColumn_ScopeTypeAlias · 0.92
ErrorMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected