BeforeEach(func() { fakeConnection.CurrentMemoryLimitsReturns(garden.MemoryLimits{}, disaster) }) It("returns the error", func() { _, err := container.CurrentMemoryLimits() Ω(err).Should(Equal(disaster)) }) }) }) Describe("Run", func() { It("sends a run request and returns the process id and a stream", func() { fakeConnection.RunStub = func(handle string, spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) { process := new(gardenfakes.FakeProcess) process.IDReturns("process-handle") process.WaitReturns(123, nil) go func() { defer GinkgoRecover() _, err := fmt.Fprintf(io.Stdout, "stdout data") Ω(err).ShouldNot(HaveOccurred()) _, err = fmt.Fprintf(io.Stderr, "stderr data") Ω(err).ShouldNot(HaveOccurred()) }() return process, nil
close(finishCreating) Eventually(stopExited).Should(BeClosed()) Eventually(created).Should(Receive()) err := apiClient.Ping() Ω(err).Should(HaveOccurred()) }) }) Context("when a Run request is in-flight", func() { It("does not wait for the request to complete", func(done Done) { fakeContainer := new(fakes.FakeContainer) fakeContainer.RunStub = func(spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) { process := new(fakes.FakeProcess) process.WaitStub = func() (int, error) { time.Sleep(time.Minute) return 0, nil } go func() { defer GinkgoRecover() _, err := io.Stdout.Write([]byte("msg 1\n")) Ω(err).ShouldNot(HaveOccurred()) time.Sleep(time.Minute) _, err = io.Stdout.Write([]byte("msg 2\n"))