|
20 | 20 | package otlptranslator |
21 | 21 |
|
22 | 22 | import ( |
| 23 | + "strings" |
23 | 24 | "testing" |
24 | | - |
25 | | - "github.com/stretchr/testify/require" |
26 | 25 | ) |
27 | 26 |
|
28 | 27 | func TestMetricNamer_Build(t *testing.T) { |
@@ -1101,22 +1100,26 @@ func TestMetricNamer_Build(t *testing.T) { |
1101 | 1100 | t.Run(tt.name, func(t *testing.T) { |
1102 | 1101 | // Build metric name using MetricNamer |
1103 | 1102 | gotMetricName := tt.namer.Build(tt.metric) |
1104 | | - require.Equal(t, tt.expectedMetricName, gotMetricName) |
| 1103 | + if tt.expectedMetricName != gotMetricName { |
| 1104 | + t.Errorf("namer.Build(%v), got %q, want %q", tt.metric, gotMetricName, tt.expectedMetricName) |
| 1105 | + } |
1105 | 1106 |
|
1106 | 1107 | // Build unit name using UnitNamer to verify correlation when suffixes are enabled |
1107 | 1108 | if tt.namer.WithMetricSuffixes { |
1108 | 1109 | unitNamer := UnitNamer{ |
1109 | 1110 | UTF8Allowed: tt.namer.UTF8Allowed, |
1110 | 1111 | } |
1111 | 1112 | gotUnitName := unitNamer.Build(tt.metric.Unit) |
1112 | | - require.Equal(t, tt.expectedUnitName, gotUnitName) |
| 1113 | + if tt.expectedUnitName != gotUnitName { |
| 1114 | + t.Errorf("unitNamer.Build(%q), got %q, want %q", tt.metric.Unit, gotUnitName, tt.expectedUnitName) |
| 1115 | + } |
1113 | 1116 |
|
1114 | 1117 | // Verify correlation: if UnitNamer produces a non-empty unit name, |
1115 | 1118 | // it should be contained in the metric name when WithMetricSuffixes=true |
1116 | 1119 | if gotUnitName != "" && tt.namer.WithMetricSuffixes { |
1117 | | - require.Contains(t, gotMetricName, gotUnitName, |
1118 | | - "Metric name '%s' should contain unit name '%s' when WithMetricSuffixes=true", |
1119 | | - gotMetricName, gotUnitName) |
| 1120 | + if !strings.Contains(gotMetricName, gotUnitName) { |
| 1121 | + t.Errorf("Metric name '%q' should contain unit name '%s' when WithMetricSuffixes=true", gotMetricName, gotUnitName) |
| 1122 | + } |
1120 | 1123 | } |
1121 | 1124 | } |
1122 | 1125 | }) |
|
0 commit comments