Example #1
0
								close(stopped)
								return nil
							}
						})

						It("stops the container", func() {
							process.Signal(os.Interrupt)
							Eventually(process.Wait()).Should(Receive(Equal(ErrInterrupted)))

							Ω(fakeContainer.StopCallCount()).Should(Equal(1))
						})
					})

					Describe("releasing", func() {
						It("releases the container", func() {
							Ω(fakeContainer.ReleaseCallCount()).Should(BeZero())

							step.Release()
							Ω(fakeContainer.ReleaseCallCount()).Should(Equal(1))
						})
					})

					Context("when running the task's script fails", func() {
						disaster := errors.New("nope")

						BeforeEach(func() {
							fakeContainer.RunReturns(nil, disaster)
						})

						It("exits with the error", func() {
							Eventually(process.Wait()).Should(Receive(Equal(disaster)))
Example #2
0
				BeforeEach(func() {
					secondFakeContainer = new(fakes.FakeContainer)
					secondFakeContainer.HandleReturns("second-fake-container")

					workerA.LookupContainerReturns(fakeContainer, nil)
					workerB.LookupContainerReturns(secondFakeContainer, nil)
				})

				It("returns a MultipleContainersError", func() {
					Ω(lookupErr).Should(BeAssignableToTypeOf(MultipleContainersError{}))
					Ω(lookupErr.(MultipleContainersError).Handles).Should(ConsistOf("fake-container", "second-fake-container"))
				})

				It("releases all returned containers", func() {
					Ω(fakeContainer.ReleaseCallCount()).Should(Equal(1))
					Ω(secondFakeContainer.ReleaseCallCount()).Should(Equal(1))
				})
			})

			Context("when a worker locates multiple containers", func() {
				var multiErr = MultipleContainersError{[]string{"a", "b"}}

				BeforeEach(func() {
					workerA.LookupContainerReturns(fakeContainer, nil)
					workerB.LookupContainerReturns(nil, multiErr)
				})

				It("returns a MultipleContainersError including the other found container", func() {
					Ω(lookupErr).Should(BeAssignableToTypeOf(MultipleContainersError{}))
					Ω(lookupErr.(MultipleContainersError).Handles).Should(ConsistOf("a", "b", "fake-container"))