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

Function TestDedicatedColumns_ToTempopb

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

Source from the content-addressed store, hash-verified

277}
278
279func TestDedicatedColumns_ToTempopb(t *testing.T) {
280 tests := []struct {
281 name string
282 cols DedicatedColumns
283 expected []*tempopb.DedicatedColumn
284 expectedErr error
285 }{
286 {
287 name: "no error",
288 cols: DedicatedColumns{
289 {Scope: DedicatedColumnScopeSpan, Name: "test.span.1", Type: DedicatedColumnTypeString},
290 {Scope: DedicatedColumnScopeResource, Name: "test.res.1", Type: DedicatedColumnTypeString},
291 {Scope: DedicatedColumnScopeResource, Name: "test.res.2", Type: DedicatedColumnTypeInt},
292 {Scope: DedicatedColumnScopeSpan, Name: "test.span.2", Type: DedicatedColumnTypeString},
293 {Scope: DedicatedColumnScopeSpan, Name: "test.span.3", Type: DedicatedColumnTypeInt, Options: DedicatedColumnOptions{}},
294 {Scope: DedicatedColumnScopeSpan, Name: "test.span.4", Type: DedicatedColumnTypeInt, Options: DedicatedColumnOptions{DedicatedColumnOptionArray}},
295 {Scope: DedicatedColumnScopeSpan, Name: "test.span.5", Type: DedicatedColumnTypeInt, Options: DedicatedColumnOptions{DedicatedColumnOptionArray, DedicatedColumnOptionBlob}},
296 },
297 expected: []*tempopb.DedicatedColumn{
298 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.1", Type: tempopb.DedicatedColumn_STRING},
299 {Scope: tempopb.DedicatedColumn_RESOURCE, Name: "test.res.1", Type: tempopb.DedicatedColumn_STRING},
300 {Scope: tempopb.DedicatedColumn_RESOURCE, Name: "test.res.2", Type: tempopb.DedicatedColumn_INT},
301 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.2", Type: tempopb.DedicatedColumn_STRING},
302 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.3", Type: tempopb.DedicatedColumn_INT},
303 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.4", Type: tempopb.DedicatedColumn_INT, Options: tempopb.DedicatedColumn_ARRAY},
304 {Scope: tempopb.DedicatedColumn_SPAN, Name: "test.span.5", Type: tempopb.DedicatedColumn_INT, Options: tempopb.DedicatedColumn_ARRAY | tempopb.DedicatedColumn_BLOB},
305 },
306 },
307 {
308 name: "wrong type",
309 cols: DedicatedColumns{
310 {Scope: DedicatedColumnScopeSpan, Name: "test.span.1", Type: DedicatedColumnType("no-type")},
311 {Scope: DedicatedColumnScopeResource, Name: "test.res.1", Type: DedicatedColumnTypeString},
312 },
313 expectedErr: errors.New("unable to convert dedicated column 'test.span.1': invalid value for dedicated column type 'no-type'"),
314 },
315 {
316 name: "wrong scope",
317 cols: DedicatedColumns{
318 {Scope: DedicatedColumnScopeResource, Name: "test.res.1", Type: DedicatedColumnTypeString},
319 {Scope: DedicatedColumnScope("no-scope"), Name: "test.span.2", Type: DedicatedColumnTypeString},
320 },
321 expectedErr: errors.New("unable to convert dedicated column 'test.span.2': invalid value for dedicated column scope 'no-scope'"),
322 },
323 {
324 name: "wrong option",
325 cols: DedicatedColumns{
326 {Scope: DedicatedColumnScopeResource, Name: "test.res.1", Type: DedicatedColumnTypeString},
327 {Scope: DedicatedColumnScopeSpan, Name: "test.span.2", Type: DedicatedColumnTypeString, Options: DedicatedColumnOptions{DedicatedColumnOptionArray, DedicatedColumnOption("no-option")}},
328 },
329 expectedErr: errors.New("unable to convert dedicated column 'test.span.2': invalid value for dedicated column option 'no-option'"),
330 },
331 }
332
333 for _, tc := range tests {
334 t.Run(tc.name, func(t *testing.T) {
335 cols, err := tc.cols.ToTempopb()
336 if tc.expectedErr != nil {

Callers

nothing calls this directly

Calls 7

DedicatedColumnTypeTypeAlias · 0.85
DedicatedColumnScopeTypeAlias · 0.85
DedicatedColumnOptionTypeAlias · 0.85
ErrorMethod · 0.65
RunMethod · 0.45
ToTempopbMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected