Skip to content

Commit 61633f4

Browse files
authored
Merge pull request #38 from prometheus/owilliams/untestify
refactor: remove uses of testify Fixes #37
2 parents a885254 + 70ddaf5 commit 61633f4

File tree

4 files changed

+17
-47
lines changed

4 files changed

+17
-47
lines changed

go.mod

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,4 @@ go 1.23.0
44

55
toolchain go1.24.1
66

7-
require (
8-
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc
9-
github.com/stretchr/testify v1.10.0
10-
)
11-
12-
require (
13-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
14-
github.com/kr/pretty v0.3.1 // indirect
15-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
16-
github.com/rogpeppe/go-internal v1.10.0 // indirect
17-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
18-
gopkg.in/yaml.v3 v3.0.1 // indirect
19-
)
7+
require github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc

go.sum

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
1-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
3-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
41
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248=
52
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
6-
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
7-
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
8-
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
9-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
10-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
11-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
12-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
13-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
14-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
15-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
16-
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
17-
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
18-
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
19-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
20-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
21-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
22-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
23-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
24-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
25-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

metric_namer_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
package otlptranslator
2121

2222
import (
23+
"strings"
2324
"testing"
24-
25-
"github.com/stretchr/testify/require"
2625
)
2726

2827
func TestMetricNamer_Build(t *testing.T) {
@@ -1101,22 +1100,26 @@ func TestMetricNamer_Build(t *testing.T) {
11011100
t.Run(tt.name, func(t *testing.T) {
11021101
// Build metric name using MetricNamer
11031102
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+
}
11051106

11061107
// Build unit name using UnitNamer to verify correlation when suffixes are enabled
11071108
if tt.namer.WithMetricSuffixes {
11081109
unitNamer := UnitNamer{
11091110
UTF8Allowed: tt.namer.UTF8Allowed,
11101111
}
11111112
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+
}
11131116

11141117
// Verify correlation: if UnitNamer produces a non-empty unit name,
11151118
// it should be contained in the metric name when WithMetricSuffixes=true
11161119
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+
}
11201123
}
11211124
}
11221125
})

normalize_label_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package otlptranslator
1919
import (
2020
"fmt"
2121
"testing"
22-
23-
"github.com/stretchr/testify/require"
2422
)
2523

2624
func TestNormalizeLabel(t *testing.T) {
@@ -46,9 +44,13 @@ func TestNormalizeLabel(t *testing.T) {
4644
result := labelNamer.Build(test.label)
4745

4846
if utf8Allowed {
49-
require.Equal(t, test.label, result)
47+
if test.label != result {
48+
t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.label)
49+
}
5050
} else {
51-
require.Equal(t, test.expected, result)
51+
if test.expected != result {
52+
t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.expected)
53+
}
5254
}
5355
})
5456
}

0 commit comments

Comments
 (0)