Skip to content

Commit

Permalink
services controller, tests: temporarily enable gomega format.MaxLength
Browse files Browse the repository at this point in the history
It is next to impossible to see the differences between expected /
actual results without the full structures being printed.

This commit adds a function that temporarily disables the maximum length
of the diff, and returns a function that when invoked puts the original
value back.

Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb committed Jul 4, 2022
1 parent bbe7133 commit 7309fc4
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/onsi/gomega"
"github.com/onsi/gomega/format"
globalconfig "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb"
ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer"
Expand Down Expand Up @@ -65,6 +66,12 @@ func (c *serviceController) close() {

// TestSyncServices - an end-to-end test for the services controller.
func TestSyncServices(t *testing.T) {
initialMaxLength := format.MaxLength
temporarilyEnableGomegaMaxLengthFormat()
t.Cleanup(func() {
restoreGomegaMaxLengthFormat(initialMaxLength)
})

ns := "testns"
serviceName := "foo"

Expand Down Expand Up @@ -628,3 +635,11 @@ func nodeConfig(nodeName string, nodeIP string) *nodeInfo {
switchName: nodeSwitchName(nodeName),
}
}

func temporarilyEnableGomegaMaxLengthFormat() {
format.MaxLength = 0
}

func restoreGomegaMaxLengthFormat(originalLength int) {
format.MaxLength = originalLength
}

0 comments on commit 7309fc4

Please sign in to comment.