summaryrefslogtreecommitdiff
path: root/test/e2e/search_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/search_test.go')
-rw-r--r--test/e2e/search_test.go79
1 files changed, 40 insertions, 39 deletions
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go
index 8c388d0ee..b0faabf6c 100644
--- a/test/e2e/search_test.go
+++ b/test/e2e/search_test.go
@@ -12,6 +12,7 @@ import (
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gexec"
)
type endpoint struct {
@@ -87,7 +88,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search", func() {
search := podmanTest.Podman([]string{"search", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue())
})
@@ -95,14 +96,14 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search single registry flag", func() {
search := podmanTest.Podman([]string{"search", "quay.io/skopeo/stable:latest"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(search.LineInOutputContains("quay.io/skopeo/stable")).To(BeTrue())
})
It("podman search image with description", func() {
search := podmanTest.Podman([]string{"search", "quay.io/libpod/whalesay"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
output := string(search.Out.Contents())
match, _ := regexp.MatchString(`(?m)^quay.io\s+quay.io/libpod/whalesay\s+Static image used for automated testing.+$`, output)
Expect(match).To(BeTrue())
@@ -111,7 +112,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search format flag", func() {
search := podmanTest.Podman([]string{"search", "--format", "table {{.Index}} {{.Name}}", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue())
})
@@ -119,7 +120,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search format json", func() {
search := podmanTest.Podman([]string{"search", "--format", "json", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(search.IsJSONOutputValid()).To(BeTrue())
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
})
@@ -127,7 +128,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search format json list tags", func() {
search := podmanTest.Podman([]string{"search", "--list-tags", "--format", "json", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(search.IsJSONOutputValid()).To(BeTrue())
Expect(search.OutputToString()).To(ContainSubstring("docker.io/library/alpine"))
Expect(search.OutputToString()).To(ContainSubstring("3.10"))
@@ -137,7 +138,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search no-trunc flag", func() {
search := podmanTest.Podman([]string{"search", "--no-trunc", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
Expect(search.LineInOutputContains("docker.io/library/alpine")).To(BeTrue())
Expect(search.LineInOutputContains("...")).To(BeFalse())
@@ -146,24 +147,24 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search limit flag", func() {
search := podmanTest.Podman([]string{"search", "docker.io/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(26))
search = podmanTest.Podman([]string{"search", "--limit", "3", "docker.io/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(4))
search = podmanTest.Podman([]string{"search", "--limit", "30", "docker.io/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(31))
})
It("podman search with filter stars", func() {
search := podmanTest.Podman([]string{"search", "--filter", "stars=10", "--format", "{{.Stars}}", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
output := search.OutputToStringArray()
for i := 0; i < len(output); i++ {
Expect(strconv.Atoi(output[i])).To(BeNumerically(">=", 10))
@@ -173,7 +174,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search with filter is-official", func() {
search := podmanTest.Podman([]string{"search", "--filter", "is-official", "--format", "{{.Official}}", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
output := search.OutputToStringArray()
for i := 0; i < len(output); i++ {
Expect(output[i]).To(Equal("[OK]"))
@@ -183,7 +184,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search with filter is-automated", func() {
search := podmanTest.Podman([]string{"search", "--filter", "is-automated=false", "--format", "{{.Automated}}", "alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
output := search.OutputToStringArray()
for i := 0; i < len(output); i++ {
Expect(output[i]).To(Equal(""))
@@ -201,7 +202,7 @@ registries = ['{{.Host}}:{{.Port}}']`
"-p", fmt.Sprintf("%s:5000", registryEndpoints[0].Port),
registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
fakereg.WaitWithDefaultTimeout()
- Expect(fakereg.ExitCode()).To(Equal(0))
+ Expect(fakereg).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -213,7 +214,7 @@ registries = ['{{.Host}}:{{.Port}}']`
// if this test succeeded, there will be no output (there is no entry named fake/image:andtag in an empty registry)
// and the exit code will be 0
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(search.OutputToString()).Should(BeEmpty())
Expect(search.ErrorToString()).Should(BeEmpty())
})
@@ -228,7 +229,7 @@ registries = ['{{.Host}}:{{.Port}}']`
"-p", fmt.Sprintf("%s:5000", registryEndpoints[3].Port), registry,
"/entrypoint.sh", "/etc/docker/registry/config.yml"})
registry.WaitWithDefaultTimeout()
- Expect(registry.ExitCode()).To(Equal(0))
+ Expect(registry).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry3", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -238,17 +239,17 @@ registries = ['{{.Host}}:{{.Port}}']`
image := fmt.Sprintf("%s/my-alpine", registryEndpoints[3].Address())
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image})
push.WaitWithDefaultTimeout()
- Expect(push.ExitCode()).To(Equal(0))
+ Expect(push).Should(Exit(0))
search := podmanTest.Podman([]string{"search", image, "--tls-verify=false"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(search.OutputToString()).ShouldNot(BeEmpty())
// podman search v2 registry with empty query
searchEmpty := podmanTest.Podman([]string{"search", fmt.Sprintf("%s/", registryEndpoints[3].Address()), "--tls-verify=false"})
searchEmpty.WaitWithDefaultTimeout()
- Expect(searchEmpty.ExitCode()).To(BeZero())
+ Expect(searchEmpty).Should(Exit(0))
Expect(len(searchEmpty.OutputToStringArray())).To(BeNumerically(">=", 1))
match, _ := search.GrepString("my-alpine")
Expect(match).Should(BeTrue())
@@ -264,7 +265,7 @@ registries = ['{{.Host}}:{{.Port}}']`
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[4].Port),
"--name", "registry4", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"})
registry.WaitWithDefaultTimeout()
- Expect(registry.ExitCode()).To(Equal(0))
+ Expect(registry).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry4", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -274,7 +275,7 @@ registries = ['{{.Host}}:{{.Port}}']`
image := fmt.Sprintf("%s/my-alpine", registryEndpoints[4].Address())
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image})
push.WaitWithDefaultTimeout()
- Expect(push.ExitCode()).To(Equal(0))
+ Expect(push).Should(Exit(0))
// registries.conf set up
var buffer bytes.Buffer
@@ -289,7 +290,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search := podmanTest.Podman([]string{"search", image})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
match, _ := search.GrepString("my-alpine")
Expect(match).Should(BeTrue())
Expect(search.ErrorToString()).Should(BeEmpty())
@@ -307,7 +308,7 @@ registries = ['{{.Host}}:{{.Port}}']`
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[5].Port),
"--name", "registry5", registry})
registry.WaitWithDefaultTimeout()
- Expect(registry.ExitCode()).To(Equal(0))
+ Expect(registry).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry5", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -317,7 +318,7 @@ registries = ['{{.Host}}:{{.Port}}']`
image := fmt.Sprintf("%s/my-alpine", registryEndpoints[5].Address())
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image})
push.WaitWithDefaultTimeout()
- Expect(push.ExitCode()).To(Equal(0))
+ Expect(push).Should(Exit(0))
var buffer bytes.Buffer
registryFileTmpl.Execute(&buffer, registryEndpoints[5])
@@ -327,7 +328,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(125))
+ Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error")
Expect(match).Should(BeTrue())
@@ -345,7 +346,7 @@ registries = ['{{.Host}}:{{.Port}}']`
registry := podmanTest.Podman([]string{"run", "-d", "-p", fmt.Sprintf("%s:5000", registryEndpoints[6].Port),
"--name", "registry6", registry})
registry.WaitWithDefaultTimeout()
- Expect(registry.ExitCode()).To(Equal(0))
+ Expect(registry).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry6", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -355,7 +356,7 @@ registries = ['{{.Host}}:{{.Port}}']`
image := fmt.Sprintf("%s/my-alpine", registryEndpoints[6].Address())
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, image})
push.WaitWithDefaultTimeout()
- Expect(push.ExitCode()).To(Equal(0))
+ Expect(push).Should(Exit(0))
var buffer bytes.Buffer
registryFileBadTmpl.Execute(&buffer, registryEndpoints[6])
@@ -370,7 +371,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search := podmanTest.Podman([]string{"search", image})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(125))
+ Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error")
Expect(match).Should(BeTrue())
@@ -391,7 +392,7 @@ registries = ['{{.Host}}:{{.Port}}']`
registryLocal := podmanTest.Podman([]string{"run", "-d", "--net=host", "-p", fmt.Sprintf("%s:5000", registryEndpoints[7].Port),
"--name", "registry7", registry})
registryLocal.WaitWithDefaultTimeout()
- Expect(registryLocal.ExitCode()).To(Equal(0))
+ Expect(registryLocal).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry7", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -399,7 +400,7 @@ registries = ['{{.Host}}:{{.Port}}']`
registryLocal = podmanTest.Podman([]string{"run", "-d", "-p", "6000:5000", "--name", "registry8", registry})
registryLocal.WaitWithDefaultTimeout()
- Expect(registryLocal.ExitCode()).To(Equal(0))
+ Expect(registryLocal).Should(Exit(0))
if !WaitContainerReady(podmanTest, "registry8", "listening on", 20, 1) {
Skip("Cannot start docker registry.")
@@ -408,7 +409,7 @@ registries = ['{{.Host}}:{{.Port}}']`
podmanTest.RestoreArtifact(ALPINE)
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"})
push.WaitWithDefaultTimeout()
- Expect(push.ExitCode()).To(Equal(0))
+ Expect(push).Should(Exit(0))
// registries.conf set up
var buffer bytes.Buffer
@@ -424,7 +425,7 @@ registries = ['{{.Host}}:{{.Port}}']`
search := podmanTest.Podman([]string{"search", "my-alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(125))
+ Expect(search).Should(Exit(125))
Expect(search.OutputToString()).Should(BeEmpty())
match, _ := search.ErrorGrepString("error")
Expect(match).Should(BeTrue())
@@ -437,35 +438,35 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search fail with nonexistent --authfile", func() {
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Not(Equal(0)))
+ Expect(search).To(ExitWithError())
})
It("podman search with wildcards", func() {
search := podmanTest.Podman([]string{"search", "--limit", "30", "registry.redhat.io/*"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(31))
search = podmanTest.Podman([]string{"search", "registry.redhat.io/*openshift*"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray()) > 1).To(BeTrue())
})
It("podman search repository tags", func() {
search := podmanTest.Podman([]string{"search", "--list-tags", "--limit", "30", "docker.io/library/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(31))
search = podmanTest.Podman([]string{"search", "--list-tags", "docker.io/library/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray()) > 2).To(BeTrue())
search = podmanTest.Podman([]string{"search", "--filter=is-official", "--list-tags", "docker.io/library/alpine"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Not(Equal(0)))
+ Expect(search).To(ExitWithError())
search = podmanTest.Podman([]string{"search", "--list-tags", "docker.io/library/"})
search.WaitWithDefaultTimeout()
@@ -475,7 +476,7 @@ registries = ['{{.Host}}:{{.Port}}']`
It("podman search with limit over 100", func() {
search := podmanTest.Podman([]string{"search", "--limit", "130", "registry.redhat.io/rhel"})
search.WaitWithDefaultTimeout()
- Expect(search.ExitCode()).To(Equal(0))
+ Expect(search).Should(Exit(0))
Expect(len(search.OutputToStringArray())).To(Equal(131))
})
})