Ejemplo n.º 1
0
					{
						Name: "./some-temp-dir/some-temp-file",
						Body: "some-body",
					},
				},
			)

			tgz, err := os.Open(tgzPath)
			Ω(err).ShouldNot(HaveOccurred())

			tarStream, err = gzip.NewReader(tgz)
			Ω(err).ShouldNot(HaveOccurred())
		})

		It("creates the files in the container", func() {
			tarInput, err := container.StreamIn("/tmp/some-container-dir")
			Ω(err).ShouldNot(HaveOccurred())

			_, err = io.Copy(tarInput, tarStream)
			Ω(err).ShouldNot(HaveOccurred())

			tarInput.Close()

			_, stream, err := container.Run(warden.ProcessSpec{
				Script: `test -f /tmp/some-container-dir/some-temp-dir/some-temp-file && exit 42`,
			})

			Expect(*(<-stream).ExitStatus).To(Equal(uint32(42)))
		})

		Context("and then copying them out", func() {
Ejemplo n.º 2
0
			It("returns the error", func() {
				_, err := container.Info()
				Ω(err).Should(Equal(disaster))
			})
		})
	})

	Describe("StreamIn", func() {
		It("sends a stream in request", func() {
			reader, w := io.Pipe()
			fakeConnection.WhenStreamingIn = func(handle string, dst string) (io.WriteCloser, error) {
				Ω(dst).Should(Equal("to"))
				return w, nil
			}

			writer, err := container.StreamIn("to")
			Ω(err).ShouldNot(HaveOccurred())

			go func() {
				writer.Write([]byte("stuff"))
				writer.Close()
			}()

			content, err := ioutil.ReadAll(reader)
			Ω(err).ShouldNot(HaveOccurred())
			Ω(string(content)).Should(Equal("stuff"))
		})

		Context("when streaming in fails", func() {
			disaster := errors.New("oh no!")