Skip to content

Commit e29a5e5

Browse files
committed
TEST/MINOR: enhance the way we display Backend and Frontend diffs when a test fail
1 parent 89ad8dd commit e29a5e5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

test/integration/base/base.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"strings"
3030
"time"
3131

32+
"github.com/google/go-cmp/cmp"
3233
rc "github.com/haproxytech/haproxy-unified-gateway/k8s/gate/conditions/routes"
3334
futils "github.com/haproxytech/haproxy-unified-gateway/k8s/gate/fileutils"
3435
dto "github.com/prometheus/client_model/go"
@@ -508,7 +509,7 @@ func (*BaseSuite) areCrtListContentEqual(expected, got []string) bool {
508509
}
509510

510511
func (b *BaseSuite) ExpectFrontends(ctx context.Context, expectationPath string, expectedFrontends []string) {
511-
var diffs map[string][]any
512+
var diffs string
512513
if !utils.WaitFor(ctx, interval, timeout, func() bool {
513514
frontends, err := b.test.HaproxyClient.FrontendsGet()
514515
if err != nil {
@@ -531,7 +532,7 @@ func (b *BaseSuite) ExpectFrontends(ctx context.Context, expectationPath string,
531532
expectedFrontend := b.FrontendFromManifest(expectationPath, expectedFeName)
532533
areSame := expectedFrontend.Equal(*gotFrontend)
533534
if !areSame {
534-
diffs = expectedFrontend.Diff(*gotFrontend)
535+
diffs = cmp.Diff(expectedFrontend, *gotFrontend)
535536
return false
536537
}
537538
}
@@ -553,7 +554,7 @@ func (b *BaseSuite) FrontendFromManifest(manifestPath, manifestName string) *mod
553554
}
554555

555556
func (b *BaseSuite) ExpectBackends(ctx context.Context, expectationPath string, expectedBackends []string) {
556-
var diffs map[string][]any
557+
var diffs string
557558
if !utils.WaitFor(ctx, interval, timeout, func() bool {
558559
backends, err := b.test.HaproxyClient.BackendsGet()
559560
if err != nil {
@@ -576,7 +577,7 @@ func (b *BaseSuite) ExpectBackends(ctx context.Context, expectationPath string,
576577
expectedBackend := b.BackendFromManifest(expectationPath, expectedBeName)
577578
areSame := expectedBackend.Equal(*gotBackend)
578579
if !areSame {
579-
diffs = expectedBackend.Diff(*gotBackend)
580+
diffs = cmp.Diff(expectedBackend, *gotBackend)
580581
return false
581582
}
582583
}

0 commit comments

Comments
 (0)