Skip to content

Commit

Permalink
Update Go tests (#1562)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
SuperQ authored Jul 15, 2024
1 parent 45f1e72 commit fec6b22
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions prometheus/collectors/go_collector_go121_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func withAllMetrics() []string {
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
"go_godebug_non_default_behavior_multipathtcp_events_total",
"go_godebug_non_default_behavior_netedns0_events_total",
"go_godebug_non_default_behavior_panicnil_events_total",
"go_godebug_non_default_behavior_randautoseed_events_total",
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
Expand Down Expand Up @@ -158,6 +159,7 @@ func withDebugMetrics() []string {
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
"go_godebug_non_default_behavior_multipathtcp_events_total",
"go_godebug_non_default_behavior_netedns0_events_total",
"go_godebug_non_default_behavior_panicnil_events_total",
"go_godebug_non_default_behavior_randautoseed_events_total",
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
Expand Down
2 changes: 2 additions & 0 deletions prometheus/collectors/go_collector_go122_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func withAllMetrics() []string {
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
"go_godebug_non_default_behavior_multipathtcp_events_total",
"go_godebug_non_default_behavior_netedns0_events_total",
"go_godebug_non_default_behavior_panicnil_events_total",
"go_godebug_non_default_behavior_randautoseed_events_total",
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
Expand Down Expand Up @@ -176,6 +177,7 @@ func withDebugMetrics() []string {
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
"go_godebug_non_default_behavior_multipathtcp_events_total",
"go_godebug_non_default_behavior_netedns0_events_total",
"go_godebug_non_default_behavior_panicnil_events_total",
"go_godebug_non_default_behavior_randautoseed_events_total",
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
Expand Down
15 changes: 8 additions & 7 deletions prometheus/collectors/go_collector_latest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"encoding/json"
"log"
"net/http"
"reflect"
"regexp"
"sort"
"testing"

"github.com/google/go-cmp/cmp"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
Expand Down Expand Up @@ -69,8 +70,8 @@ func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) {
got = append(got, r.GetName())
}

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

Expand Down Expand Up @@ -127,8 +128,8 @@ func TestGoCollectorAllowList(t *testing.T) {
got = append(got, r.GetName())
}

if !reflect.DeepEqual(got, test.expected) {
t.Errorf("got %v, want %v", got, test.expected)
if diff := cmp.Diff(got, test.expected); diff != "" {
t.Errorf("missmatch (-want +got):\n%s", diff)
}
})
}
Expand Down Expand Up @@ -181,8 +182,8 @@ func TestGoCollectorDenyList(t *testing.T) {
got = append(got, r.GetName())
}

if !reflect.DeepEqual(got, test.expected) {
t.Errorf("got %v, want %v", got, test.expected)
if diff := cmp.Diff(got, test.expected); diff != "" {
t.Errorf("missmatch (-want +got):\n%s", diff)
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion prometheus/go_collector_metrics_go121_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion prometheus/go_collector_metrics_go122_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fec6b22

Please sign in to comment.