]> git.feebdaed.xyz Git - 0xmirror/cilium.git/commitdiff
pkg/hubble: replace reflect.DeepEqual in tests
authorAshwin Pillai <pillaiashwin96@gmail.com>
Tue, 16 Dec 2025 20:51:22 +0000 (12:51 -0800)
committerSebastian Wicki <sebastian@isovalent.com>
Wed, 17 Dec 2025 09:23:23 +0000 (09:23 +0000)
Replace reflect.DeepEqual with assert.Equal from testify in hubble test
files for better error messages when assertions fail.

Signed-off-by: Ashwin Pillai <pillaiashwin96@gmail.com>
pkg/hubble/metrics/metrics_test.go
pkg/hubble/parser/seven/kafka_test.go

index 43b9a760b02fbd38f013357c9f5e1e05ecd2f83e..51fe4e8d0eb663703f64b9920d5d45352472d319 100644 (file)
@@ -10,7 +10,6 @@ import (
        "log/slog"
        "net/http"
        "net/http/httptest"
-       "reflect"
        "sort"
        "testing"
        "time"
@@ -238,7 +237,7 @@ func assertHandlersInDfp(t *testing.T, dfp *DynamicFlowProcessor, cfg *api.Confi
        for _, m := range dfp.Metrics {
                _, ok := names[m.Name]
                assert.True(t, ok)
-               assert.True(t, reflect.DeepEqual(*m.MetricConfig, *(names[m.Name])))
+               assert.Equal(t, *(names[m.Name]), *m.MetricConfig)
        }
 }
 
index 458e54663ee1227e4fe922ff0c674fa091cc0bcc..763babdd1c4e9f26d180207592cec73b7e8d31a4 100644 (file)
@@ -4,9 +4,10 @@
 package seven
 
 import (
-       "reflect"
        "testing"
 
+       "github.com/stretchr/testify/assert"
+
        flowpb "github.com/cilium/cilium/api/v1/flow"
        "github.com/cilium/cilium/pkg/hubble/defaults"
        "github.com/cilium/cilium/pkg/hubble/parser/options"
@@ -143,9 +144,7 @@ func Test_decodeKafka(t *testing.T) {
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
                        got := decodeKafka(tt.args.flowType, tt.args.kafka, tt.args.opts)
-                       if !reflect.DeepEqual(got, tt.want) {
-                               t.Errorf("decodeKafka() = %v, want %v", got, tt.want)
-                       }
+                       assert.Equal(t, tt.want, got)
                })
        }
 }