diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/inspect_test.go | 15 | ||||
-rw-r--r-- | test/utils/utils.go | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index c2e0f4407..97f77414e 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -7,6 +7,7 @@ import ( . "github.com/containers/podman/v2/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" "github.com/opencontainers/selinux/go-selinux" ) @@ -428,4 +429,18 @@ var _ = Describe("Podman inspect", func() { Expect(inspect).To(ExitWithError()) }) + // Fixes https://github.com/containers/podman/issues/8444 + It("podman inspect --format json .NetworkSettings.Ports", func() { + ctnrName := "Ctnr_" + RandomString(25) + + create := podmanTest.Podman([]string{"create", "--name", ctnrName, "-p", "8080:80", ALPINE}) + create.WaitWithDefaultTimeout() + Expect(create).Should(Exit(0)) + + inspect := podmanTest.Podman([]string{"inspect", `--format="{{json .NetworkSettings.Ports}}"`, ctnrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).Should(Exit(0)) + Expect(inspect.OutputToString()).To(Equal(`"{"80/tcp":[{"HostIp":"","HostPort":"8080"}]}"`)) + }) + }) diff --git a/test/utils/utils.go b/test/utils/utils.go index d08939678..027e96427 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "math/rand" "os" "os/exec" "runtime" @@ -465,3 +466,16 @@ func Containerized() bool { } return false } + +var randomLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +// RandomString returns a string of given length composed of random characters +func RandomString(n int) string { + rand.Seed(GinkgoRandomSeed()) + + b := make([]rune, n) + for i := range b { + b[i] = randomLetters[rand.Intn(len(randomLetters))] + } + return string(b) +} |