예제 #1
0
			BeforeEach(func() {
				performing = make(chan struct{})
				cancelled := make(chan struct{})

				fakeStep1.PerformStub = func() error {
					close(performing)

					select {
					case <-cancelled:
						return steps.ErrCancelled
					}
				}

				fakeStep1.CancelStub = func() {
					close(cancelled)
				}
			})

			It("cancels the in-flight check", func() {
				performResult := make(chan error)

				go func() { performResult <- step.Perform() }()

				expectCheckAfterInterval(fakeStep1, unhealthyInterval)

				Eventually(performing).Should(BeClosed())

				step.Cancel()

				Eventually(performResult).Should(Receive(Equal(steps.ErrCancelled)))
예제 #2
0
			BeforeEach(func() {
				cancelledError = errors.New("I was cancelled yo.")
				cancelled2 := make(chan bool, 1)

				subStep1.PerformStub = func() error {
					return nil
				}

				subStep2.PerformStub = func() error {
					<-cancelled2
					return cancelledError
				}

				subStep2.CancelStub = func() {
					cancelled2 <- true
				}
			})

			JustBeforeEach(func() {
				errCh = make(chan error)

				go func() {
					errCh <- step.Perform()
				}()
			})

			It("continues to perform the other step", func() {
				Consistently(errCh).ShouldNot(Receive())

				By("cancelling, it should return")