github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/inspect_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/kata-containers/tests" 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/ginkgo/extensions/table" 13 . "github.com/onsi/gomega" 14 ) 15 16 func inspectFormatOptions(formatOption string, expectedStdout string) TableEntry { 17 return Entry(fmt.Sprintf("inspect with %s will give you as stdout %s", formatOption, expectedStdout), formatOption, expectedStdout) 18 } 19 20 var _ = Describe("inspect", func() { 21 var ( 22 id string 23 ) 24 25 BeforeEach(func() { 26 id = randomDockerName() 27 _, _, exitCode := dockerRun("-d", "--name", id, Image) 28 Expect(exitCode).To(Equal(0)) 29 }) 30 31 AfterEach(func() { 32 Expect(RemoveDockerContainer(id)).To(BeTrue()) 33 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 34 }) 35 36 DescribeTable("inspect with docker", 37 func(formatOption string, expectedStdout string) { 38 stdout, _, _ := dockerInspect("--format", formatOption, id) 39 Expect(stdout).To(ContainSubstring(expectedStdout)) 40 }, 41 inspectFormatOptions("'{{.Config.Image}}'", Image), 42 inspectFormatOptions("'{{.HostConfig.Runtime}}'", Runtime), 43 inspectFormatOptions("'{{json .Config}}'", Image), 44 ) 45 })