Skip to content

Commit

Permalink
a few more manual BeTrue cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Ed Santiago <[email protected]>
  • Loading branch information
edsantiago committed Nov 30, 2021
1 parent f7cbb1d commit 8eb0be0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions test/e2e/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})

Expand All @@ -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"))
})

Expand All @@ -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"))
})

Expand Down
7 changes: 3 additions & 4 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
"strings"
"time"

"github.com/containers/podman/v3/libpod/network/types"
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/runlabel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion test/e2e/volume_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package integration

import (
"os"
"strings"

. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
Expand Down
14 changes: 7 additions & 7 deletions test/utils/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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")
}

0 comments on commit 8eb0be0

Please sign in to comment.