} }) It("bubbles the error up", func() { process, err := container.Attach(42, garden.ProcessIO{}) Ω(err).ShouldNot(HaveOccurred()) _, err = process.Wait() Ω(err).Should(HaveOccurred()) Ω(err.Error()).Should(ContainSubstring("oh no!")) }) }) Context("when attaching fails", func() { BeforeEach(func() { fakeContainer.AttachReturns(nil, errors.New("oh no!")) }) It("fails", func() { _, err := container.Attach(123, garden.ProcessIO{}) Ω(err).Should(HaveOccurred()) }) It("closes the stdin writer", func(done Done) { container.Attach(123, garden.ProcessIO{}) _, processIO := fakeContainer.AttachArgsForCall(0) _, err := processIO.Stdin.Read([]byte{}) Ω(err).Should(Equal(io.EOF)) close(done)