diff options
author | Valentin Rothberg <vrothberg@suse.com> | 2018-03-14 07:46:14 +0100 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-14 14:01:53 +0000 |
commit | 62b93d172399c20753914d7d91d02ee105a77f6d (patch) | |
tree | 7a0784c0cf68c45f800d28375c9fec551523644f /test/e2e | |
parent | 9b2f81b07bd5d2a1e0fef391022ad39090d547d0 (diff) | |
download | podman-62b93d172399c20753914d7d91d02ee105a77f6d.tar.gz podman-62b93d172399c20753914d7d91d02ee105a77f6d.tar.bz2 podman-62b93d172399c20753914d7d91d02ee105a77f6d.zip |
test/e2e/images_test.go: test with multiple tags
As podman-images(1) had some issues correctly reporting all RepoTags of
an image (in the default format), extend the e2e tests to avoid running
into similar in the future.
Signed-off-by: Valentin Rothberg <vrothberg@suse.com>
Closes: #477
Approved by: rhatdan
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/images_test.go | 22 | ||||
-rw-r--r-- | test/e2e/libpod_suite_test.go | 36 |
2 files changed, 58 insertions, 0 deletions
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index ecc0f2415..e05281ac9 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -37,6 +37,28 @@ var _ = Describe("Podman images", func() { Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) }) + It("podman images with multiple tags", func() { + // tag "docker.io/library/alpine:latest" to "foo:{a,b,c}" + session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // tag "foo:c" to "bar:{a,b}" + session = podmanTest.Podman([]string{"tag", "foo:c", "bar:a", "bar:b"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + // check all previous and the newly tagged images + session = podmanTest.Podman([]string{"images"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session.LineInOutputContainsTag("docker.io/library/alpine", "latest") + session.LineInOutputContainsTag("docker.io/library/busybox", "glibc") + session.LineInOutputContainsTag("foo", "a") + session.LineInOutputContainsTag("foo", "b") + session.LineInOutputContainsTag("foo", "c") + session.LineInOutputContainsTag("bar", "a") + session.LineInOutputContainsTag("bar", "b") + }) + It("podman images with digests", func() { session := podmanTest.Podman([]string{"images", "--digests"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index ed9694092..6938ea571 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -445,6 +445,42 @@ func (s *PodmanSession) LineInOuputContains(term string) bool { return false } +//tagOutPutToMap parses each string in imagesOutput and returns +// a map of repo:tag pairs. Notice, the first array item will +// be skipped as it's considered to be the header. +func tagOutputToMap(imagesOutput []string) map[string]string { + m := make(map[string]string) + // iterate over output but skip the header + for _, i := range imagesOutput[1:] { + tmp := []string{} + for _, x := range strings.Split(i, " ") { + if x != "" { + tmp = append(tmp, x) + } + } + // podman-images(1) return a list like output + // in the format of "Repository Tag [...]" + if len(tmp) < 2 { + continue + } + m[tmp[0]] = tmp[1] + } + return m +} + +//LineInOutputContainsTag returns true if a line in the +// session's output contains the repo-tag pair as returned +// by podman-images(1). +func (s *PodmanSession) LineInOutputContainsTag(repo, tag string) bool { + tagMap := tagOutputToMap(s.OutputToStringArray()) + for r, t := range tagMap { + if repo == r && tag == t { + return true + } + } + return false +} + //GetContainerStatus returns the containers state. // This function assumes only one container is active. func (p *PodmanTest) GetContainerStatus() string { |