Skip to content

Commit fec6b22

Browse files
authored
Update Go tests (#1562)
Add new metric that appeared in 1.22.5 and 1.21.12. * Improve test output with `cmp.Diff`. Signed-off-by: SuperQ <[email protected]>
1 parent 45f1e72 commit fec6b22

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

prometheus/collectors/go_collector_go121_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func withAllMetrics() []string {
6363
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
6464
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
6565
"go_godebug_non_default_behavior_multipathtcp_events_total",
66+
"go_godebug_non_default_behavior_netedns0_events_total",
6667
"go_godebug_non_default_behavior_panicnil_events_total",
6768
"go_godebug_non_default_behavior_randautoseed_events_total",
6869
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
@@ -158,6 +159,7 @@ func withDebugMetrics() []string {
158159
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
159160
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
160161
"go_godebug_non_default_behavior_multipathtcp_events_total",
162+
"go_godebug_non_default_behavior_netedns0_events_total",
161163
"go_godebug_non_default_behavior_panicnil_events_total",
162164
"go_godebug_non_default_behavior_randautoseed_events_total",
163165
"go_godebug_non_default_behavior_tarinsecurepath_events_total",

prometheus/collectors/go_collector_go122_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func withAllMetrics() []string {
6666
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
6767
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
6868
"go_godebug_non_default_behavior_multipathtcp_events_total",
69+
"go_godebug_non_default_behavior_netedns0_events_total",
6970
"go_godebug_non_default_behavior_panicnil_events_total",
7071
"go_godebug_non_default_behavior_randautoseed_events_total",
7172
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
@@ -176,6 +177,7 @@ func withDebugMetrics() []string {
176177
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
177178
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
178179
"go_godebug_non_default_behavior_multipathtcp_events_total",
180+
"go_godebug_non_default_behavior_netedns0_events_total",
179181
"go_godebug_non_default_behavior_panicnil_events_total",
180182
"go_godebug_non_default_behavior_randautoseed_events_total",
181183
"go_godebug_non_default_behavior_tarinsecurepath_events_total",

prometheus/collectors/go_collector_latest_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import (
2020
"encoding/json"
2121
"log"
2222
"net/http"
23-
"reflect"
2423
"regexp"
2524
"sort"
2625
"testing"
2726

27+
"github.com/google/go-cmp/cmp"
28+
2829
"github.com/prometheus/client_golang/prometheus"
2930
"github.com/prometheus/client_golang/prometheus/promhttp"
3031
)
@@ -69,8 +70,8 @@ func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) {
6970
got = append(got, r.GetName())
7071
}
7172

72-
if !reflect.DeepEqual(got, baseMetrics) {
73-
t.Errorf("got %v, want %v", got, baseMetrics)
73+
if diff := cmp.Diff(got, baseMetrics); diff != "" {
74+
t.Errorf("missmatch (-want +got):\n%s", diff)
7475
}
7576
}
7677

@@ -127,8 +128,8 @@ func TestGoCollectorAllowList(t *testing.T) {
127128
got = append(got, r.GetName())
128129
}
129130

130-
if !reflect.DeepEqual(got, test.expected) {
131-
t.Errorf("got %v, want %v", got, test.expected)
131+
if diff := cmp.Diff(got, test.expected); diff != "" {
132+
t.Errorf("missmatch (-want +got):\n%s", diff)
132133
}
133134
})
134135
}
@@ -181,8 +182,8 @@ func TestGoCollectorDenyList(t *testing.T) {
181182
got = append(got, r.GetName())
182183
}
183184

184-
if !reflect.DeepEqual(got, test.expected) {
185-
t.Errorf("got %v, want %v", got, test.expected)
185+
if diff := cmp.Diff(got, test.expected); diff != "" {
186+
t.Errorf("missmatch (-want +got):\n%s", diff)
186187
}
187188
})
188189
}

prometheus/go_collector_metrics_go121_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prometheus/go_collector_metrics_go122_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)