Skip to content

Commit

Permalink
fix unstable gomega match for large nested dex policies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ti-afra committed Dec 18, 2024
1 parent 1bfb739 commit 853adca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/render/dex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package render_test

import (
"encoding/json"
"fmt"

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

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

0 comments on commit 853adca

Please sign in to comment.