Find and fix empty Expect()s

That previous commit made me wonder if there are any other
instances of Expect() with no assertions.

   grep Expect test/e2e/*_test.go |egrep -v '\.(To|NotTo|Should)'

...finds a couple of handfuls, most of which are OK (continued
on the next line) but a few of which are bugs. Fix those.

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago
2021-11-23 07:33:35 -07:00
parent c034147fe7
commit eb3708a524
3 changed files with 14 additions and 12 deletions

View File

@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
"strings"
"sync"
"time"
@ -62,12 +61,10 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray()) >= 1)
Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of events")
})
It("podman events with an event filter and container=cid", func() {
Skip("Does not work on v2")
SkipIfNotFedora()
_, ec, cid := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
_, ec2, cid2 := podmanTest.RunLsContainer("")
@ -76,8 +73,10 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start", "--filter", fmt.Sprintf("container=%s", cid)})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(Equal(1))
Expect(!strings.Contains(result.OutputToString(), cid2))
events := result.OutputToStringArray()
Expect(len(events)).To(Equal(1), "number of events")
Expect(events[0]).To(ContainSubstring(cid), "event log includes CID")
Expect(events[0]).To(Not(ContainSubstring(cid2)), "event log does not include second CID")
})
It("podman events with a type and filter container=id", func() {
@ -101,8 +100,12 @@ var _ = Describe("Podman events", func() {
result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", "pod=foobarpod"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
fmt.Println(result.OutputToStringArray())
Expect(len(result.OutputToStringArray()) >= 2)
events := result.OutputToStringArray()
fmt.Println(events)
Expect(len(events)).To(BeNumerically(">=", 2), "Number of events")
Expect(events).To(ContainElement(ContainSubstring(" pod create ")))
Expect(events).To(ContainElement(ContainSubstring(" pod stop ")))
Expect(events).To(ContainElement(ContainSubstring("name=foobarpod")))
})
It("podman events --since", func() {

View File

@ -2,7 +2,6 @@ package integration
import (
"os"
"strings"
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
@ -61,7 +60,7 @@ var _ = Describe("Podman inspect", func() {
Expect(inspect).Should(Exit(0))
// output should not be empty
// test validates fix for https://github.com/containers/podman/issues/8785
Expect(strings.Contains(inspect.OutputToString(), "TEST"))
Expect(inspect.OutputToString()).To(ContainSubstring("TEST="), ".Config.Env")
session = podmanTest.Podman([]string{"rmi", "envwithtab"})
session.WaitWithDefaultTimeout()
@ -76,7 +75,7 @@ var _ = Describe("Podman inspect", func() {
result := podmanTest.Podman([]string{"images", "-q", "--no-trunc", ALPINE})
result.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(strings.Contains(result.OutputToString(), session.OutputToString()))
Expect(result.OutputToStringArray()).To(ContainElement("sha256:"+session.OutputToString()), "'podman images -q --no-truncate' includes 'podman inspect --format .ID'")
})
It("podman inspect specified type", func() {

View File

@ -230,7 +230,7 @@ default-docker:
Expect(session).Should(Exit(0))
ids := session.OutputToStringArray()
Expect(len(RESTORE_IMAGES), len(ids))
Expect(len(ids)).To(BeNumerically(">", 1), "We need to have *some* images to save")
multiImageSave(podmanTest, ids)
})
})