github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/export_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 "path/filepath" 6 7 . "github.com/containers/libpod/test/utils" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("Podman export", 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.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 34 }) 35 36 It("podman export output flag", func() { 37 SkipIfRemote() 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.ExitCode()).To(Equal(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 SkipIfRemote() 54 _, ec, cid := podmanTest.RunLsContainer("") 55 Expect(ec).To(Equal(0)) 56 57 outfile := filepath.Join(podmanTest.TempDir, "container.tar") 58 result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid}) 59 result.WaitWithDefaultTimeout() 60 Expect(result.ExitCode()).To(Equal(0)) 61 _, err := os.Stat(outfile) 62 Expect(err).To(BeNil()) 63 64 err = os.Remove(outfile) 65 Expect(err).To(BeNil()) 66 }) 67 68 It("podman export bad filename", func() { 69 _, ec, cid := podmanTest.RunLsContainer("") 70 Expect(ec).To(Equal(0)) 71 72 outfile := filepath.Join(podmanTest.TempDir, "container:with:colon.tar") 73 result := podmanTest.Podman([]string{"export", "-o", outfile, cid}) 74 result.WaitWithDefaultTimeout() 75 Expect(result).To(ExitWithError()) 76 }) 77 })