From 8eb0be0a29a647308b3ed9eab2126e1004b6ba85 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 30 Nov 2021 10:00:17 -0700 Subject: a few more manual BeTrue cleanups Signed-off-by: Ed Santiago --- test/e2e/load_test.go | 6 +++--- test/e2e/network_test.go | 7 +++---- test/e2e/runlabel_test.go | 4 ++-- test/e2e/volume_inspect_test.go | 1 - test/utils/matchers.go | 14 +++++++------- 5 files changed, 15 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index 030e9f80b..ad5634e0c 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -221,7 +221,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "hello:world"}) result.WaitWithDefaultTimeout() - Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) + Expect(result.OutputToString()).To(Not(ContainSubstring("docker"))) Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) @@ -246,7 +246,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "hello:latest"}) result.WaitWithDefaultTimeout() - Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) + Expect(result.OutputToString()).To(Not(ContainSubstring("docker"))) Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) @@ -272,7 +272,7 @@ var _ = Describe("Podman load", func() { result := podmanTest.Podman([]string{"images", "load:latest"}) result.WaitWithDefaultTimeout() - Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) + Expect(result.OutputToString()).To(Not(ContainSubstring("docker"))) Expect(result.OutputToString()).To(ContainSubstring("localhost")) }) diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index aab996e02..ff306f0f8 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "os" - "strings" "time" "github.com/containers/podman/v3/libpod/network/types" @@ -269,7 +268,7 @@ var _ = Describe("Podman network", func() { Expect(ok).To(BeTrue()) Expect(net.NetworkID).To(Equal(netName)) Expect(net.IPPrefixLen).To(Equal(24)) - Expect(strings.HasPrefix(net.IPAddress, "10.50.50.")).To(BeTrue()) + Expect(net.IPAddress).To(HavePrefix("10.50.50.")) // Necessary to ensure the CNI network is removed cleanly rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) @@ -342,12 +341,12 @@ var _ = Describe("Podman network", func() { Expect(ok).To(BeTrue()) Expect(net1.NetworkID).To(Equal(netName1)) Expect(net1.IPPrefixLen).To(Equal(25)) - Expect(strings.HasPrefix(net1.IPAddress, "10.50.51.")).To(BeTrue()) + Expect(net1.IPAddress).To(HavePrefix("10.50.51.")) net2, ok := conData[0].NetworkSettings.Networks[netName2] Expect(ok).To(BeTrue()) Expect(net2.NetworkID).To(Equal(netName2)) Expect(net2.IPPrefixLen).To(Equal(26)) - Expect(strings.HasPrefix(net2.IPAddress, "10.50.51.")).To(BeTrue()) + Expect(net2.IPAddress).To(HavePrefix("10.50.51.")) // Necessary to ensure the CNI network is removed cleanly rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index e473119b2..b7b27dc14 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -94,14 +94,14 @@ var _ = Describe("podman container runlabel", func() { result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) // should not panic when label missing the value or don't have the label - Expect(result.LineInOutputContains("panic")).NotTo(BeTrue()) + Expect(result.OutputToString()).To(Not(ContainSubstring("panic"))) }) It("podman container runlabel bogus label in remote image should result in non-zero exit", func() { result := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"}) result.WaitWithDefaultTimeout() Expect(result).To(ExitWithError()) // should not panic when label missing the value or don't have the label - Expect(result.LineInOutputContains("panic")).NotTo(BeTrue()) + Expect(result.OutputToString()).To(Not(ContainSubstring("panic"))) }) It("podman container runlabel global options", func() { diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go index 055be5b19..172063b90 100644 --- a/test/e2e/volume_inspect_test.go +++ b/test/e2e/volume_inspect_test.go @@ -2,7 +2,6 @@ package integration import ( "os" - "strings" . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" diff --git a/test/utils/matchers.go b/test/utils/matchers.go index 59436a3ab..288779b63 100644 --- a/test/utils/matchers.go +++ b/test/utils/matchers.go @@ -168,18 +168,18 @@ func (matcher *ExitMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { return true } -type validJSONMatcher struct { +type ValidJSONMatcher struct { types.GomegaMatcher } -func BeValidJSON() *validJSONMatcher { - return &validJSONMatcher{} +func BeValidJSON() *ValidJSONMatcher { + return &ValidJSONMatcher{} } -func (matcher *validJSONMatcher) Match(actual interface{}) (success bool, err error) { +func (matcher *ValidJSONMatcher) Match(actual interface{}) (success bool, err error) { s, ok := actual.(string) if !ok { - return false, fmt.Errorf("validJSONMatcher expects a string, not %q", actual) + return false, fmt.Errorf("ValidJSONMatcher expects a string, not %q", actual) } var i interface{} @@ -189,10 +189,10 @@ func (matcher *validJSONMatcher) Match(actual interface{}) (success bool, err er return true, nil } -func (matcher *validJSONMatcher) FailureMessage(actual interface{}) (message string) { +func (matcher *ValidJSONMatcher) FailureMessage(actual interface{}) (message string) { return format.Message(actual, "to be valid JSON") } -func (matcher *validJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) { +func (matcher *ValidJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) { return format.Message(actual, "to _not_ be valid JSON") } -- cgit v1.2.3-54-g00ecf