(t *testing.T)
| 763 | } |
| 764 | |
| 765 | func TestNewEncoder_OpenMetricsVersionDispatch(t *testing.T) { |
| 766 | counterMetric := &dto.MetricFamily{ |
| 767 | Name: proto.String("test_counter"), |
| 768 | Type: dto.MetricType_COUNTER.Enum(), |
| 769 | Metric: []*dto.Metric{ |
| 770 | { |
| 771 | Counter: &dto.Counter{ |
| 772 | Value: proto.Float64(42), |
| 773 | CreatedTimestamp: ×tamppb.Timestamp{ |
| 774 | Seconds: 1234567890, |
| 775 | Nanos: 0, |
| 776 | }, |
| 777 | }, |
| 778 | }, |
| 779 | }, |
| 780 | } |
| 781 | |
| 782 | tests := []struct { |
| 783 | name string |
| 784 | format Format |
| 785 | expectedLine string |
| 786 | }{ |
| 787 | { |
| 788 | name: "OpenMetrics 1.0.0", |
| 789 | format: FmtOpenMetrics_1_0_0, |
| 790 | expectedLine: "# TYPE test_counter unknown\ntest_counter 42.0\n", |
| 791 | }, |
| 792 | { |
| 793 | name: "OpenMetrics 0.0.1", |
| 794 | format: FmtOpenMetrics_0_0_1, |
| 795 | expectedLine: "# TYPE test_counter unknown\ntest_counter 42.0\n", |
| 796 | }, |
| 797 | { |
| 798 | name: "OpenMetrics 2.0.0-rc standard", |
| 799 | format: FmtOpenMetrics_2_0_0_rc, |
| 800 | expectedLine: "# TYPE test_counter counter\ntest_counter 42.0 st@1234567890\n", |
| 801 | }, |
| 802 | { |
| 803 | name: "OpenMetrics 2.0.0 standard", |
| 804 | format: FmtOpenMetrics_2_0_0, |
| 805 | expectedLine: "# TYPE test_counter counter\ntest_counter 42.0 st@1234567890\n", |
| 806 | }, |
| 807 | { |
| 808 | name: "OpenMetrics 2.0.0 reordered parameters", |
| 809 | format: Format("application/openmetrics-text; charset=utf-8; version=2.0.0"), |
| 810 | expectedLine: "# TYPE test_counter counter\ntest_counter 42.0 st@1234567890\n", |
| 811 | }, |
| 812 | { |
| 813 | name: "OpenMetrics 2.0.0 quoted version parameter", |
| 814 | format: Format(`application/openmetrics-text; version="2.0.0"; charset=utf-8`), |
| 815 | expectedLine: "# TYPE test_counter counter\ntest_counter 42.0 st@1234567890\n", |
| 816 | }, |
| 817 | { |
| 818 | name: "OpenMetrics 2.0.0 with escaping scheme", |
| 819 | format: Format("application/openmetrics-text; version=2.0.0; charset=utf-8; escaping=values"), |
| 820 | expectedLine: "# TYPE test_counter counter\ntest_counter 42.0 st@1234567890\n", |
| 821 | }, |
| 822 | } |
nothing calls this directly
no test coverage detected