Context("when the raw event source returns sse.ErrSourceClosed", func() { BeforeEach(func() { fakeRawEventSource.NextReturns(sse.Event{}, sse.ErrSourceClosed) }) It("returns models.ErrSourceClosed", func() { _, err := eventSource.Next() Expect(err).To(Equal(events.ErrSourceClosed)) }) }) }) Describe("Close", func() { Context("when the raw source closes normally", func() { It("closes the raw event source", func() { eventSource.Close() Expect(fakeRawEventSource.CloseCallCount()).To(Equal(1)) }) It("does not error", func() { err := eventSource.Close() Expect(err).NotTo(HaveOccurred()) }) }) Context("when the raw source closes with error", func() { var rawError error BeforeEach(func() { rawError = errors.New("ka-boom") fakeRawEventSource.CloseReturns(rawError)