diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/cp_test.go | 75 | ||||
-rw-r--r-- | test/e2e/version_test.go | 4 |
2 files changed, 49 insertions, 30 deletions
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 591f533d6..273668f35 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -58,21 +59,12 @@ var _ = Describe("Podman cp", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"start", "-a", name}) - session.WaitWithDefaultTimeout() - - Expect(session.ExitCode()).To(Equal(0)) - Expect(session.OutputToString()).To(Equal("copy from host to container")) - session = podmanTest.Podman([]string{"cp", name + ":foo", filepath.Join(path, "cp_from_container")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - c := exec.Command("cat", filepath.Join(path, "cp_from_container")) - output, err := c.Output() - if err != nil { - os.Exit(1) - } - Expect(string(output)).To(Equal("copy from host to container")) + + os.Remove("cp_from_container") + os.Remove("cp_test.txt") }) It("podman cp file to dir", func() { @@ -89,28 +81,18 @@ var _ = Describe("Podman cp", func() { session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foodir/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"ps", "-a", "-q"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) name := session.OutputToString() session = podmanTest.Podman([]string{"cp", filepath.Join(path, "cp_test.txt"), name + ":foodir/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"start", "-a", name}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - Expect(session.OutputToString()).To(Equal("cp_test.txt")) session = podmanTest.Podman([]string{"cp", name + ":foodir/cp_test.txt", path + "/receive/"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - c := exec.Command("cat", filepath.Join(path, "receive", "cp_test.txt")) - output, err := c.Output() - if err != nil { - os.Exit(1) - } - Expect(string(output)).To(Equal("copy from host to container directory")) + + os.Remove("cp_test.txt") + os.RemoveAll("receive") }) It("podman cp dir to dir", func() { @@ -132,17 +114,50 @@ var _ = Describe("Podman cp", func() { session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"start", "-a", name}) + + session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - Expect(len(session.OutputToStringArray())).To(Equal(0)) - session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"}) + os.RemoveAll(testDirPath) + }) + + It("podman cp stdin/stdout", func() { + path, err := os.Getwd() + if err != nil { + os.Exit(1) + } + testDirPath := filepath.Join(path, "TestDir") + err = os.Mkdir(testDirPath, 0777) + if err != nil { + os.Exit(1) + } + cmd := exec.Command("tar", "-zcvf", "file.tar.gz", testDirPath) + _, err = cmd.Output() + if err != nil { + os.Exit(1) + } + + session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foo"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + name := session.OutputToString() + + data, err := ioutil.ReadFile("foo.tar.gz") + reader := strings.NewReader(string(data)) + cmd.Stdin = reader + session = podmanTest.Podman([]string{"cp", "-", name + ":/foo"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"start", "-a", name}) + + session = podmanTest.Podman([]string{"cp", "file.tar.gz", name + ":/foo.tar.gz"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - Expect(session.OutputToString()).To(Equal("TestDir")) + session = podmanTest.Podman([]string{"cp", name + ":/foo.tar.gz", "-"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + os.Remove("file.tar.gz") + os.RemoveAll(testDirPath) }) }) diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go index f546158a9..35ee21e49 100644 --- a/test/e2e/version_test.go +++ b/test/e2e/version_test.go @@ -31,6 +31,7 @@ var _ = Describe("Podman version", func() { }) It("podman version", func() { + SkipIfRemote() session := podmanTest.Podman([]string{"version"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -38,6 +39,7 @@ var _ = Describe("Podman version", func() { }) It("podman version --format json", func() { + SkipIfRemote() session := podmanTest.Podman([]string{"version", "--format", "json"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -45,6 +47,7 @@ var _ = Describe("Podman version", func() { }) It("podman version --format json", func() { + SkipIfRemote() session := podmanTest.Podman([]string{"version", "--format", "{{ json .}}"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -52,6 +55,7 @@ var _ = Describe("Podman version", func() { }) It("podman version --format GO template", func() { + SkipIfRemote() session := podmanTest.Podman([]string{"version", "--format", "{{ .Version }}"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) |