(t *testing.T)
| 497 | } |
| 498 | |
| 499 | func TestDottedEncode(t *testing.T) { |
| 500 | //nolint:staticcheck |
| 501 | model.NameValidationScheme = model.UTF8Validation |
| 502 | metric := &dto.MetricFamily{ |
| 503 | Name: proto.String("foo.metric"), |
| 504 | Type: dto.MetricType_COUNTER.Enum(), |
| 505 | Metric: []*dto.Metric{ |
| 506 | { |
| 507 | Counter: &dto.Counter{ |
| 508 | Value: proto.Float64(1.234), |
| 509 | }, |
| 510 | }, |
| 511 | { |
| 512 | Label: []*dto.LabelPair{ |
| 513 | { |
| 514 | Name: proto.String("dotted.label.name"), |
| 515 | Value: proto.String("my.label.value"), |
| 516 | }, |
| 517 | }, |
| 518 | Counter: &dto.Counter{ |
| 519 | Value: proto.Float64(8), |
| 520 | }, |
| 521 | }, |
| 522 | }, |
| 523 | } |
| 524 | |
| 525 | scenarios := []struct { |
| 526 | format Format |
| 527 | expectMetricName string |
| 528 | expectLabelName string |
| 529 | }{ |
| 530 | { |
| 531 | format: FmtProtoDelim, |
| 532 | expectMetricName: "foo_metric", |
| 533 | expectLabelName: "dotted_label_name", |
| 534 | }, |
| 535 | { |
| 536 | format: FmtProtoDelim.WithEscapingScheme(model.NoEscaping), |
| 537 | expectMetricName: "foo.metric", |
| 538 | expectLabelName: "dotted.label.name", |
| 539 | }, |
| 540 | { |
| 541 | format: FmtProtoDelim.WithEscapingScheme(model.DotsEscaping), |
| 542 | expectMetricName: "foo_dot_metric", |
| 543 | expectLabelName: "dotted_dot_label_dot_name", |
| 544 | }, |
| 545 | { |
| 546 | format: FmtText, |
| 547 | expectMetricName: "foo_metric", |
| 548 | expectLabelName: "dotted_label_name", |
| 549 | }, |
| 550 | { |
| 551 | format: FmtText.WithEscapingScheme(model.NoEscaping), |
| 552 | expectMetricName: "foo.metric", |
| 553 | expectLabelName: "dotted.label.name", |
| 554 | }, |
| 555 | { |
| 556 | format: FmtText.WithEscapingScheme(model.DotsEscaping), |
nothing calls this directly
no test coverage detected