func tryInBackground(monitRetryStrategy boshretry.RetryStrategy) chan error { errChan := make(chan error) go func() { errChan <- monitRetryStrategy.Try() }() return errChan }
retryable.AddAttemptBehavior(nil, true, errors.New("request error")) } retryable.AddAttemptBehavior(nil, true, lastError) errChan := tryInBackground(monitRetryStrategy) Eventually(errChan).Should(Receive(Equal(lastError))) Expect(retryable.Attempts()).To(Equal(maxOtherAttempts)) }) }) Context("when attempt is not retryable", func() { It("does not retry", func() { retryable.AddAttemptBehavior(nil, false, lastError) err := monitRetryStrategy.Try() Expect(err).To(Equal(lastError)) Expect(retryable.AttemptCalled).To(Equal(1)) }) It("closes the response body", func() { retryable.AddAttemptBehavior(unavailable, false, lastError) err := monitRetryStrategy.Try() Expect(err).To(Equal(lastError)) Expect(retryable.Response().Body.(ClosedChecker).Closed()).To(BeTrue()) }) }) }) })