Skip to content

Commit 35b3cc3

Browse files
committed
fix unstable gomega match for large nested dex policies
gomega Expect was not able to compare correctly the dex policies and would fail when running in "Run" mode but pass when running in "Debug" mode. It was also passing when we print the values before the Expect().To() call. To fix this, we convert the larger and nested struct to String and compare the string values.
1 parent aad7d58 commit 35b3cc3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/render/dex_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package render_test
1616

1717
import (
18+
"encoding/json"
1819
"fmt"
1920

2021
. "github.com/onsi/ginkgo"
@@ -526,7 +527,9 @@ var _ = Describe("dex rendering tests", func() {
526527

527528
policy := testutils.GetAllowTigeraPolicyFromResources(policyName, resources)
528529
expectedPolicy := getExpectedPolicy(scenario)
529-
Expect(policy).To(Equal(expectedPolicy))
530+
policyJ, _ := json.Marshal(policy)
531+
expectedPolicyJ, _ := json.Marshal(expectedPolicy)
532+
Expect(string(policyJ)).To(Equal(string(expectedPolicyJ)))
530533
},
531534
// Dex only renders in the presence of an Authentication CR, therefore does not have a config option for managed clusters.
532535
Entry("for management/standalone, kube-dns", testutils.AllowTigeraScenario{ManagedCluster: false, OpenShift: false}),

0 commit comments

Comments
 (0)