github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/volume_inspect_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  	"strings"
     6  
     7  	. "github.com/containers/libpod/test/utils"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    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  		podmanTest.SeedImages()
    27  	})
    28  
    29  	AfterEach(func() {
    30  		podmanTest.CleanupVolume()
    31  		f := CurrentGinkgoTestDescription()
    32  		processTestResult(f)
    33  
    34  	})
    35  
    36  	It("podman inspect volume", func() {
    37  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
    38  		session.WaitWithDefaultTimeout()
    39  		volName := session.OutputToString()
    40  		Expect(session.ExitCode()).To(Equal(0))
    41  
    42  		session = podmanTest.Podman([]string{"volume", "inspect", volName})
    43  		session.WaitWithDefaultTimeout()
    44  		Expect(session.ExitCode()).To(Equal(0))
    45  		Expect(session.IsJSONOutputValid()).To(BeTrue())
    46  	})
    47  
    48  	It("podman inspect volume with Go format", func() {
    49  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
    50  		session.WaitWithDefaultTimeout()
    51  		volName := session.OutputToString()
    52  		Expect(session.ExitCode()).To(Equal(0))
    53  
    54  		session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", volName})
    55  		session.WaitWithDefaultTimeout()
    56  		Expect(session.ExitCode()).To(Equal(0))
    57  		Expect(session.OutputToString()).To(Equal(volName))
    58  	})
    59  
    60  	It("podman inspect volume with --all flag", func() {
    61  		session := podmanTest.Podman([]string{"volume", "create", "myvol1"})
    62  		session.WaitWithDefaultTimeout()
    63  		volName1 := session.OutputToString()
    64  		Expect(session.ExitCode()).To(Equal(0))
    65  
    66  		session = podmanTest.Podman([]string{"volume", "create", "myvol2"})
    67  		session.WaitWithDefaultTimeout()
    68  		volName2 := session.OutputToString()
    69  		Expect(session.ExitCode()).To(Equal(0))
    70  
    71  		session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", "--all"})
    72  		session.WaitWithDefaultTimeout()
    73  		Expect(session.ExitCode()).To(Equal(0))
    74  		Expect(len(session.OutputToStringArray())).To(Equal(2))
    75  		Expect(session.OutputToStringArray()[0]).To(Equal(volName1))
    76  		Expect(session.OutputToStringArray()[1]).To(Equal(volName2))
    77  	})
    78  
    79  	It("inspect volume finds options", func() {
    80  		volName := "testvol"
    81  		session := podmanTest.Podman([]string{"volume", "create", "--opt", "type=tmpfs", volName})
    82  		session.WaitWithDefaultTimeout()
    83  		Expect(session.ExitCode()).To(Equal(0))
    84  
    85  		inspect := podmanTest.Podman([]string{"volume", "inspect", volName})
    86  		inspect.WaitWithDefaultTimeout()
    87  		Expect(inspect.ExitCode()).To(Equal(0))
    88  		Expect(strings.Contains(inspect.OutputToString(), "tmpfs")).To(BeTrue())
    89  	})
    90  })