a few more manual BeTrue cleanups

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago 2021-11-30 10:00:17 -07:00
parent f7cbb1d845
commit 8eb0be0a29
5 changed files with 15 additions and 17 deletions

View File

@ -221,7 +221,7 @@ var _ = Describe("Podman load", func() {
result := podmanTest.Podman([]string{"images", "hello:world"}) result := podmanTest.Podman([]string{"images", "hello:world"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.OutputToString()).To(Not(ContainSubstring("docker")))
Expect(result.OutputToString()).To(ContainSubstring("localhost")) Expect(result.OutputToString()).To(ContainSubstring("localhost"))
}) })
@ -246,7 +246,7 @@ var _ = Describe("Podman load", func() {
result := podmanTest.Podman([]string{"images", "hello:latest"}) result := podmanTest.Podman([]string{"images", "hello:latest"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.OutputToString()).To(Not(ContainSubstring("docker")))
Expect(result.OutputToString()).To(ContainSubstring("localhost")) Expect(result.OutputToString()).To(ContainSubstring("localhost"))
}) })
@ -272,7 +272,7 @@ var _ = Describe("Podman load", func() {
result := podmanTest.Podman([]string{"images", "load:latest"}) result := podmanTest.Podman([]string{"images", "load:latest"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue())) Expect(result.OutputToString()).To(Not(ContainSubstring("docker")))
Expect(result.OutputToString()).To(ContainSubstring("localhost")) Expect(result.OutputToString()).To(ContainSubstring("localhost"))
}) })

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
"strings"
"time" "time"
"github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/libpod/network/types"
@ -269,7 +268,7 @@ var _ = Describe("Podman network", func() {
Expect(ok).To(BeTrue()) Expect(ok).To(BeTrue())
Expect(net.NetworkID).To(Equal(netName)) Expect(net.NetworkID).To(Equal(netName))
Expect(net.IPPrefixLen).To(Equal(24)) 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 // Necessary to ensure the CNI network is removed cleanly
rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName})
@ -342,12 +341,12 @@ var _ = Describe("Podman network", func() {
Expect(ok).To(BeTrue()) Expect(ok).To(BeTrue())
Expect(net1.NetworkID).To(Equal(netName1)) Expect(net1.NetworkID).To(Equal(netName1))
Expect(net1.IPPrefixLen).To(Equal(25)) 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] net2, ok := conData[0].NetworkSettings.Networks[netName2]
Expect(ok).To(BeTrue()) Expect(ok).To(BeTrue())
Expect(net2.NetworkID).To(Equal(netName2)) Expect(net2.NetworkID).To(Equal(netName2))
Expect(net2.IPPrefixLen).To(Equal(26)) 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 // Necessary to ensure the CNI network is removed cleanly
rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName}) rmAll := podmanTest.Podman([]string{"rm", "-t", "0", "-f", ctrName})

View File

@ -94,14 +94,14 @@ var _ = Describe("podman container runlabel", func() {
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError()) Expect(result).To(ExitWithError())
// should not panic when label missing the value or don't have the label // 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() { 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 := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"})
result.WaitWithDefaultTimeout() result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError()) Expect(result).To(ExitWithError())
// should not panic when label missing the value or don't have the label // 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() { It("podman container runlabel global options", func() {

View File

@ -2,7 +2,6 @@ package integration
import ( import (
"os" "os"
"strings"
. "github.com/containers/podman/v3/test/utils" . "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View File

@ -168,18 +168,18 @@ func (matcher *ExitMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
return true return true
} }
type validJSONMatcher struct { type ValidJSONMatcher struct {
types.GomegaMatcher types.GomegaMatcher
} }
func BeValidJSON() *validJSONMatcher { func BeValidJSON() *ValidJSONMatcher {
return &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) s, ok := actual.(string)
if !ok { 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{} var i interface{}
@ -189,10 +189,10 @@ func (matcher *validJSONMatcher) Match(actual interface{}) (success bool, err er
return true, nil 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") 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") return format.Message(actual, "to _not_ be valid JSON")
} }