github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/export_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 "path/filepath" 6 7 . "github.com/containers/podman/v3/test/utils" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("Podman export", func() { 14 var ( 15 tempdir string 16 err error 17 podmanTest *PodmanTestIntegration 18 ) 19 20 BeforeEach(func() { 21 tempdir, err = CreateTempDirInTempDir() 22 if err != nil { 23 os.Exit(1) 24 } 25 podmanTest = PodmanTestCreate(tempdir) 26 podmanTest.Setup() 27 podmanTest.SeedImages() 28 }) 29 30 AfterEach(func() { 31 podmanTest.Cleanup() 32 f := CurrentGinkgoTestDescription() 33 processTestResult(f) 34 35 }) 36 37 It("podman export output flag", func() { 38 _, ec, cid := podmanTest.RunLsContainer("") 39 Expect(ec).To(Equal(0)) 40 41 outfile := filepath.Join(podmanTest.TempDir, "container.tar") 42 result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) 43 result.WaitWithDefaultTimeout() 44 Expect(result).Should(Exit(0)) 45 _, err := os.Stat(outfile) 46 Expect(err).To(BeNil()) 47 48 err = os.Remove(outfile) 49 Expect(err).To(BeNil()) 50 }) 51 52 It("podman container export output flag", func() { 53 _, ec, cid := podmanTest.RunLsContainer("") 54 Expect(ec).To(Equal(0)) 55 56 outfile := filepath.Join(podmanTest.TempDir, "container.tar") 57 result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid}) 58 result.WaitWithDefaultTimeout() 59 Expect(result).Should(Exit(0)) 60 _, err := os.Stat(outfile) 61 Expect(err).To(BeNil()) 62 63 err = os.Remove(outfile) 64 Expect(err).To(BeNil()) 65 }) 66 67 It("podman export bad filename", func() { 68 _, ec, cid := podmanTest.RunLsContainer("") 69 Expect(ec).To(Equal(0)) 70 71 outfile := filepath.Join(podmanTest.TempDir, "container:with:colon.tar") 72 result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) 73 result.WaitWithDefaultTimeout() 74 Expect(result).To(ExitWithError()) 75 }) 76 })