(t *testing.T)
| 219 | } |
| 220 | |
| 221 | func 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 |
nothing calls this directly
no test coverage detected