github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/port_test.go (about)

     1  // Copyright (c) 2018 Intel Corporation
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package docker
     6  
     7  import (
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  var _ = Describe("port", func() {
    13  	var (
    14  		args []string
    15  		id   string
    16  	)
    17  
    18  	BeforeEach(func() {
    19  		id = randomDockerName()
    20  		_, _, exitCode := dockerRun("-td", "-p", "50000:50000", "--name", id, Image)
    21  		Expect(exitCode).To(Equal(0))
    22  	})
    23  
    24  	AfterEach(func() {
    25  		Expect(RemoveDockerContainer(id)).To(BeTrue())
    26  		Expect(ExistDockerContainer(id)).NotTo(BeTrue())
    27  	})
    28  
    29  	Describe("port with docker", func() {
    30  		Context("specify a port in a container", func() {
    31  			It("should return assigned port", func() {
    32  				args = []string{id, "50000/tcp"}
    33  				stdout, _, _ := dockerPort(args...)
    34  				Expect(stdout).To(ContainSubstring("50000"))
    35  			})
    36  		})
    37  	})
    38  })