summaryrefslogtreecommitdiff
path: root/test/e2e/libpod_suite_test.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-02-02 11:02:09 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-02 22:44:40 +0000
commit6ba6ecf59b9204d36388de07b866f157a4d13957 (patch)
tree53bc85dd3e9820eb09014b1db2f8d136e86f6799 /test/e2e/libpod_suite_test.go
parent3ea23f84818a816104ccdcf6b836ac4bb3a7c366 (diff)
downloadpodman-6ba6ecf59b9204d36388de07b866f157a4d13957.tar.gz
podman-6ba6ecf59b9204d36388de07b866f157a4d13957.tar.bz2
podman-6ba6ecf59b9204d36388de07b866f157a4d13957.zip
Migrate Create|Commit to ginkgo
Migrate create and commit bats tests to the ginkgo test suite. In doing so, some structures had to be moved to pkg/podmanstructs/podmanstructs.go so we could do better verification of test results. Signed-off-by: baude <bbaude@redhat.com> Closes: #286 Approved by: rhatdan
Diffstat (limited to 'test/e2e/libpod_suite_test.go')
-rw-r--r--test/e2e/libpod_suite_test.go45
1 files changed, 44 insertions, 1 deletions
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index be9be93d8..27848517f 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -21,6 +21,7 @@ import (
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/pkg/errors"
+ "github.com/projectatomic/libpod/pkg/inspect"
)
// - CRIO_ROOT=/var/tmp/checkout PODMAN_BINARY=/usr/bin/podman CONMON_BINARY=/usr/libexec/crio/conmon PAPR=1 sh .papr.sh
@@ -218,12 +219,29 @@ func (s *PodmanSession) IsJSONOutputValid() bool {
var i interface{}
if err := json.Unmarshal(s.Out.Contents(), &i); err != nil {
fmt.Println(err)
- fmt.Println(s.OutputToString())
return false
}
return true
}
+// InspectContainerToJSON takes the session output of an inspect
+// container and returns json
+func (s *PodmanSession) InspectContainerToJSON() inspect.ContainerData {
+ var i inspect.ContainerData
+ err := json.Unmarshal(s.Out.Contents(), &i)
+ Expect(err).To(BeNil())
+ return i
+}
+
+// InspectImageJSON takes the session output of an inspect
+// image and returns json
+func (s *PodmanSession) InspectImageJSON() inspect.ImageData {
+ var i inspect.ImageData
+ err := json.Unmarshal(s.Out.Contents(), &i)
+ Expect(err).To(BeNil())
+ return i
+}
+
func (s *PodmanSession) WaitWithDefaultTimeout() {
s.Wait(defaultWaitTimeout)
}
@@ -370,3 +388,28 @@ func (p *PodmanTest) NumberOfContainersRunning() int {
}
return len(containers)
}
+
+//NumberOfContainersreturns an int of how many
+// containers are currently defined.
+func (p *PodmanTest) NumberOfContainers() int {
+ var containers []string
+ ps := p.Podman([]string{"ps", "-aq"})
+ ps.WaitWithDefaultTimeout()
+ Expect(ps.ExitCode()).To(Equal(0))
+ for _, i := range ps.OutputToStringArray() {
+ if i != "" {
+ containers = append(containers, i)
+ }
+ }
+ return len(containers)
+}
+
+// StringInSlice determines if a string is in a string slice, returns bool
+func StringInSlice(s string, sl []string) bool {
+ for _, i := range sl {
+ if i == s {
+ return true
+ }
+ }
+ return false
+}