}) It("does not error", func() { Expect(err).NotTo(HaveOccurred()) }) }) }) Context("When the timeout expires before the substep finishes", func() { BeforeEach(func() { substepPerformTime = 100 * time.Millisecond timeout = 10 * time.Millisecond }) It("cancels the substep", func() { Expect(substep.CancelCallCount()).To(Equal(1)) }) It("waits until the substep completes performing", func() { Expect(substepFinishedChan).To(BeClosed()) }) It("logs the timeout", func() { Eventually(logger.TestSink.LogMessages).Should(ConsistOf([]string{ "test.timeout-step.timed-out", })) }) Context("when the substep does not error", func() { BeforeEach(func() { substepPerformError = nil
subStep2 = &fakes.FakeStep{ PerformStub: func() error { return nil }, } }) It("returns an aggregate of the failures", func() { err := step.Perform() Expect(err.(*multierror.Error).WrappedErrors()).To(ConsistOf(disaster)) }) It("cancels all the steps", func() { step.Perform() Expect(subStep1.CancelCallCount()).To(Equal(1)) Expect(subStep2.CancelCallCount()).To(Equal(1)) }) }) Context("when one of the substeps exits without failure", func() { var ( cancelledError, err error errCh chan error ) BeforeEach(func() { cancelledError = errors.New("I was cancelled yo.") cancelled2 := make(chan bool, 1) subStep1.PerformStub = func() error {