github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/attach_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 "fmt" 9 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("docker attach", func() { 15 var ( 16 id string 17 exitCode int 18 containerExitCode int 19 destroyTimeout int 20 ) 21 22 BeforeEach(func() { 23 containerExitCode = 13 24 destroyTimeout = 10 25 id = randomDockerName() 26 }) 27 28 AfterEach(func() { 29 Expect(RemoveDockerContainer(id)).To(BeTrue()) 30 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 31 }) 32 33 Context("check attach functionality", func() { 34 It("should attach exit code", func() { 35 _, _, exitCode = dockerRun("--name", id, "-d", Image, "sh", "-c", 36 fmt.Sprintf("sleep %d && exit %d", destroyTimeout, containerExitCode)) 37 Expect(exitCode).To(Equal(0)) 38 _, _, exitCode = dockerAttach(id) 39 Expect(exitCode).To(Equal(containerExitCode)) 40 }) 41 }) 42 })