github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/save_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "github.com/containers/libpod/pkg/rootless" 8 . "github.com/containers/libpod/test/utils" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Podman save", 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.RestoreAllArtifacts() 28 }) 29 30 AfterEach(func() { 31 podmanTest.Cleanup() 32 f := CurrentGinkgoTestDescription() 33 processTestResult(f) 34 35 }) 36 37 It("podman save output flag", func() { 38 outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") 39 40 save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE}) 41 save.WaitWithDefaultTimeout() 42 Expect(save.ExitCode()).To(Equal(0)) 43 }) 44 45 It("podman save oci flag", func() { 46 outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") 47 48 save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE}) 49 save.WaitWithDefaultTimeout() 50 Expect(save.ExitCode()).To(Equal(0)) 51 }) 52 53 It("podman save with stdout", func() { 54 Skip("Pipe redirection in ginkgo probably won't work") 55 outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") 56 57 save := podmanTest.PodmanNoCache([]string{"save", ALPINE, ">", outfile}) 58 save.WaitWithDefaultTimeout() 59 Expect(save.ExitCode()).To(Equal(0)) 60 }) 61 62 It("podman save quiet flag", func() { 63 outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") 64 65 save := podmanTest.PodmanNoCache([]string{"save", "-q", "-o", outfile, ALPINE}) 66 save.WaitWithDefaultTimeout() 67 Expect(save.ExitCode()).To(Equal(0)) 68 }) 69 70 It("podman save bogus image", func() { 71 outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") 72 73 save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "FOOBAR"}) 74 save.WaitWithDefaultTimeout() 75 Expect(save).To(ExitWithError()) 76 }) 77 78 It("podman save to directory with oci format", func() { 79 if rootless.IsRootless() && podmanTest.RemoteTest { 80 Skip("Requires a fix in containers image for chown/lchown") 81 } 82 outdir := filepath.Join(podmanTest.TempDir, "save") 83 84 save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE}) 85 save.WaitWithDefaultTimeout() 86 Expect(save.ExitCode()).To(Equal(0)) 87 }) 88 89 It("podman save to directory with v2s2 docker format", func() { 90 if rootless.IsRootless() && podmanTest.RemoteTest { 91 Skip("Requires a fix in containers image for chown/lchown") 92 } 93 outdir := filepath.Join(podmanTest.TempDir, "save") 94 95 save := podmanTest.PodmanNoCache([]string{"save", "--format", "docker-dir", "-o", outdir, ALPINE}) 96 save.WaitWithDefaultTimeout() 97 Expect(save.ExitCode()).To(Equal(0)) 98 }) 99 100 It("podman save to directory with docker format and compression", func() { 101 if rootless.IsRootless() && podmanTest.RemoteTest { 102 Skip("Requires a fix in containers image for chown/lchown") 103 } 104 outdir := filepath.Join(podmanTest.TempDir, "save") 105 106 save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) 107 save.WaitWithDefaultTimeout() 108 Expect(save.ExitCode()).To(Equal(0)) 109 }) 110 111 It("podman save bad filename", func() { 112 outdir := filepath.Join(podmanTest.TempDir, "save:colon") 113 114 save := podmanTest.PodmanNoCache([]string{"save", "--compress", "--format", "docker-dir", "-o", outdir, ALPINE}) 115 save.WaitWithDefaultTimeout() 116 Expect(save).To(ExitWithError()) 117 }) 118 119 It("podman save image with digest reference", func() { 120 // pull a digest reference 121 session := podmanTest.PodmanNoCache([]string{"pull", ALPINELISTDIGEST}) 122 session.WaitWithDefaultTimeout() 123 Expect(session.ExitCode()).To(Equal(0)) 124 125 // save a digest reference should exit without error. 126 outfile := filepath.Join(podmanTest.TempDir, "temp.tar") 127 save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINELISTDIGEST}) 128 save.WaitWithDefaultTimeout() 129 Expect(save.ExitCode()).To(Equal(0)) 130 }) 131 })