Skip to content

Commit

Permalink
Rename 'helper.JsonSatisfies' into 'helper.JsonStatisfiesAll' to make…
Browse files Browse the repository at this point in the history
… the intent clearer
  • Loading branch information
rm3l committed Jun 26, 2023
1 parent 12f1f56 commit 6a2f36a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tests/helper/helper_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/onsi/gomega/types"
"os"
"path/filepath"
"regexp"
Expand All @@ -15,6 +14,8 @@ import (
"testing"
"time"

"github.com/onsi/gomega/types"

"github.com/tidwall/gjson"

"github.com/redhat-developer/odo/pkg/config"
Expand Down Expand Up @@ -325,8 +326,8 @@ func JsonPathContentContain(json string, path string, value string) {
Expect(result.String()).To(ContainSubstring(value), fmt.Sprintf("content of path %q should contain %q but is %q", path, value, result.String()))
}

// JsonPathSatisfies expects content of the path to satisfy all the matchers passed to it
func JsonPathSatisfies(json string, path string, matchers ...types.GomegaMatcher) {
// JsonPathSatisfiesAll expects content of the path to satisfy all the matchers passed to it
func JsonPathSatisfiesAll(json string, path string, matchers ...types.GomegaMatcher) {
result := gjson.Get(json, path)
Expect(result.String()).Should(SatisfyAll(matchers...))
}
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ var _ = Describe("odo generic", func() {
By("checking the JSON output", func() {
odoVersion = helper.Cmd("odo", "version", "-o", "json").ShouldPass().Out()
Expect(helper.IsJSON(odoVersion)).To(BeTrue())
helper.JsonPathSatisfies(odoVersion, "version", MatchRegexp(reJSONVersion))
helper.JsonPathSatisfiesAll(odoVersion, "version", MatchRegexp(reJSONVersion))
helper.JsonPathExist(odoVersion, "gitCommit")
if podman {
helper.JsonPathSatisfies(odoVersion, "podman.client.version", MatchRegexp(reJSONVersion), Equal(helper.GetPodmanVersion()))
helper.JsonPathSatisfiesAll(odoVersion, "podman.client.version", MatchRegexp(reJSONVersion), Equal(helper.GetPodmanVersion()))
} else {
helper.JsonPathSatisfies(odoVersion, "cluster.kubernetes.version", MatchRegexp(reJSONVersion))
helper.JsonPathSatisfiesAll(odoVersion, "cluster.kubernetes.version", MatchRegexp(reJSONVersion))
serverURL := oc.GetCurrentServerURL()
helper.JsonPathContentIs(odoVersion, "cluster.serverURL", serverURL)
if !helper.IsKubernetesCluster() {
Expand All @@ -169,7 +169,7 @@ var _ = Describe("odo generic", func() {
// A blank serverVersion might indicate a user permission error on certain clusters (observed with a developer account on Prow nightly jobs)
m = Not(m)
}
helper.JsonPathSatisfies(odoVersion, "cluster.openshift", m)
helper.JsonPathSatisfiesAll(odoVersion, "cluster.openshift", m)
}
}
})
Expand Down Expand Up @@ -205,10 +205,10 @@ var _ = Describe("odo generic", func() {
By("checking JSON output", func() {
odoVersion := helper.Cmd("odo", "version", "--client", "-o", "json").ShouldPass().Out()
Expect(helper.IsJSON(odoVersion)).To(BeTrue())
helper.JsonPathSatisfies(odoVersion, "version", MatchRegexp(reJSONVersion))
helper.JsonPathSatisfiesAll(odoVersion, "version", MatchRegexp(reJSONVersion))
helper.JsonPathExist(odoVersion, "gitCommit")
helper.JsonPathSatisfies(odoVersion, "cluster", BeEmpty())
helper.JsonPathSatisfies(odoVersion, "podman", BeEmpty())
helper.JsonPathSatisfiesAll(odoVersion, "cluster", BeEmpty())
helper.JsonPathSatisfiesAll(odoVersion, "podman", BeEmpty())
})
})
})
Expand Down

0 comments on commit 6a2f36a

Please sign in to comment.