github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/volume_inspect_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/hanks177/podman/v4/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("Podman volume inspect", func() {
    13  	var (
    14  		tempdir    string
    15  		err        error
    16  		podmanTest *PodmanTestIntegration
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		tempdir, err = CreateTempDirInTempDir()
    21  		if err != nil {
    22  			os.Exit(1)
    23  		}
    24  		podmanTest = PodmanTestCreate(tempdir)
    25  		podmanTest.Setup()
    26  	})
    27  
    28  	AfterEach(func() {
    29  		podmanTest.CleanupVolume()
    30  		f := CurrentGinkgoTestDescription()
    31  		processTestResult(f)
    32  
    33  	})
    34  
    35  	It("podman inspect volume", func() {
    36  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
    37  		session.WaitWithDefaultTimeout()
    38  		volName := session.OutputToString()
    39  		Expect(session).Should(Exit(0))
    40  
    41  		session = podmanTest.Podman([]string{"volume", "inspect", volName})
    42  		session.WaitWithDefaultTimeout()
    43  		Expect(session).Should(Exit(0))
    44  		Expect(session.OutputToString()).To(BeValidJSON())
    45  	})
    46  
    47  	It("podman inspect volume with Go format", func() {
    48  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
    49  		session.WaitWithDefaultTimeout()
    50  		volName := session.OutputToString()
    51  		Expect(session).Should(Exit(0))
    52  
    53  		session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", volName})
    54  		session.WaitWithDefaultTimeout()
    55  		Expect(session).Should(Exit(0))
    56  		Expect(session.OutputToString()).To(Equal(volName))
    57  	})
    58  
    59  	It("podman inspect volume with --all flag", func() {
    60  		session := podmanTest.Podman([]string{"volume", "create", "myvol1"})
    61  		session.WaitWithDefaultTimeout()
    62  		volName1 := session.OutputToString()
    63  		Expect(session).Should(Exit(0))
    64  
    65  		session = podmanTest.Podman([]string{"volume", "create", "myvol2"})
    66  		session.WaitWithDefaultTimeout()
    67  		volName2 := session.OutputToString()
    68  		Expect(session).Should(Exit(0))
    69  
    70  		session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", "--all"})
    71  		session.WaitWithDefaultTimeout()
    72  		Expect(session).Should(Exit(0))
    73  		Expect(session.OutputToStringArray()).To(HaveLen(2))
    74  		Expect(session.OutputToStringArray()[0]).To(Equal(volName1))
    75  		Expect(session.OutputToStringArray()[1]).To(Equal(volName2))
    76  	})
    77  
    78  	It("inspect volume finds options", func() {
    79  		volName := "testvol"
    80  		session := podmanTest.Podman([]string{"volume", "create", "--opt", "type=tmpfs", volName})
    81  		session.WaitWithDefaultTimeout()
    82  		Expect(session).Should(Exit(0))
    83  
    84  		inspect := podmanTest.Podman([]string{"volume", "inspect", volName})
    85  		inspect.WaitWithDefaultTimeout()
    86  		Expect(inspect).Should(Exit(0))
    87  		Expect(inspect.OutputToString()).To(ContainSubstring("tmpfs"))
    88  	})
    89  })