github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/test/e2e/volume_create_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	. "github.com/containers/podman/v2/test/utils"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  var _ = Describe("Podman volume create", 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 create volume", func() {
    37  		session := podmanTest.Podman([]string{"volume", "create"})
    38  		session.WaitWithDefaultTimeout()
    39  		volName := session.OutputToString()
    40  		Expect(session.ExitCode()).To(Equal(0))
    41  
    42  		check := podmanTest.Podman([]string{"volume", "ls", "-q"})
    43  		check.WaitWithDefaultTimeout()
    44  		match, _ := check.GrepString(volName)
    45  		Expect(match).To(BeTrue())
    46  		Expect(len(check.OutputToStringArray())).To(Equal(1))
    47  	})
    48  
    49  	It("podman create volume with name", func() {
    50  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
    51  		session.WaitWithDefaultTimeout()
    52  		volName := session.OutputToString()
    53  		Expect(session.ExitCode()).To(Equal(0))
    54  
    55  		check := podmanTest.Podman([]string{"volume", "ls", "-q"})
    56  		check.WaitWithDefaultTimeout()
    57  		match, _ := check.GrepString(volName)
    58  		Expect(match).To(BeTrue())
    59  		Expect(len(check.OutputToStringArray())).To(Equal(1))
    60  	})
    61  
    62  	It("podman create volume with bad volume option", func() {
    63  		session := podmanTest.Podman([]string{"volume", "create", "--opt", "badOpt=bad"})
    64  		session.WaitWithDefaultTimeout()
    65  		Expect(session).To(ExitWithError())
    66  	})
    67  
    68  	It("podman create volume with o=uid,gid", func() {
    69  		volName := "testVol"
    70  		uid := "3000"
    71  		gid := "4000"
    72  		session := podmanTest.Podman([]string{"volume", "create", "--opt", fmt.Sprintf("o=uid=%s,gid=%s", uid, gid), volName})
    73  		session.WaitWithDefaultTimeout()
    74  		Expect(session.ExitCode()).To(Equal(0))
    75  
    76  		inspectUID := podmanTest.Podman([]string{"volume", "inspect", "--format", "{{ .UID }}", volName})
    77  		inspectUID.WaitWithDefaultTimeout()
    78  		Expect(inspectUID.ExitCode()).To(Equal(0))
    79  		Expect(inspectUID.OutputToString()).To(Equal(uid))
    80  
    81  		inspectGID := podmanTest.Podman([]string{"volume", "inspect", "--format", "{{ .GID }}", volName})
    82  		inspectGID.WaitWithDefaultTimeout()
    83  		Expect(inspectGID.ExitCode()).To(Equal(0))
    84  		Expect(inspectGID.OutputToString()).To(Equal(gid))
    85  	})
    86  })