MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestConvertMetadata

Function TestConvertMetadata

tools/thanosconvert/thanosconvert_test.go:293–403  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestConvertMetadata(t *testing.T) {
294 tests := []struct {
295 name string
296 expectedUser string
297 in metadata.Meta
298 out metadata.Meta
299 changesRequired []string
300 }{
301 {
302 name: "no changes required",
303 expectedUser: "user1",
304 in: metadata.Meta{
305 Thanos: metadata.Thanos{
306 Labels: map[string]string{
307 cortex_tsdb.TenantIDExternalLabel: "user1",
308 },
309 },
310 },
311 out: metadata.Meta{
312 Thanos: metadata.Thanos{
313 Labels: map[string]string{
314 cortex_tsdb.TenantIDExternalLabel: "user1",
315 },
316 },
317 },
318 changesRequired: []string{},
319 },
320 {
321 name: "add __org_id__ label",
322 expectedUser: "user1",
323 in: metadata.Meta{
324 Thanos: metadata.Thanos{
325 Labels: map[string]string{},
326 },
327 },
328 out: metadata.Meta{
329 Thanos: metadata.Thanos{
330 Labels: map[string]string{
331 cortex_tsdb.TenantIDExternalLabel: "user1",
332 },
333 },
334 },
335 changesRequired: []string{"add __org_id__ label"},
336 },
337 {
338 name: "nil labels map",
339 expectedUser: "user1",
340 in: metadata.Meta{
341 Thanos: metadata.Thanos{
342 Labels: nil,
343 },
344 },
345 out: metadata.Meta{
346 Thanos: metadata.Thanos{
347 Labels: map[string]string{
348 cortex_tsdb.TenantIDExternalLabel: "user1",
349 },
350 },

Callers

nothing calls this directly

Calls 3

convertMetadataFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected