github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/export_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 "path/filepath" 6 7 . "github.com/hanks177/podman/v4/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 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 34 }) 35 36 It("podman export output flag", func() { 37 _, ec, cid := podmanTest.RunLsContainer("") 38 Expect(ec).To(Equal(0)) 39 40 outfile := filepath.Join(podmanTest.TempDir, "container.tar") 41 result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) 42 result.WaitWithDefaultTimeout() 43 Expect(result).Should(Exit(0)) 44 _, err := os.Stat(outfile) 45 Expect(err).To(BeNil()) 46 47 err = os.Remove(outfile) 48 Expect(err).To(BeNil()) 49 }) 50 51 It("podman container export output flag", func() { 52 _, ec, cid := podmanTest.RunLsContainer("") 53 Expect(ec).To(Equal(0)) 54 55 outfile := filepath.Join(podmanTest.TempDir, "container.tar") 56 result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid}) 57 result.WaitWithDefaultTimeout() 58 Expect(result).Should(Exit(0)) 59 _, err := os.Stat(outfile) 60 Expect(err).To(BeNil()) 61 62 err = os.Remove(outfile) 63 Expect(err).To(BeNil()) 64 }) 65 66 It("podman export bad filename", func() { 67 _, ec, cid := podmanTest.RunLsContainer("") 68 Expect(ec).To(Equal(0)) 69 70 outfile := filepath.Join(podmanTest.TempDir, "container:with:colon.tar") 71 result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) 72 result.WaitWithDefaultTimeout() 73 Expect(result).To(ExitWithError()) 74 }) 75 })