}) }) Context("when the container cannot be found on the worker", func() { BeforeEach(func() { fakeWorker.LookupContainerReturns(nil, false, nil) }) It("expires the container and returns false and no error", func() { _, found, err := pool.LookupContainer(logger, "some-handle") Expect(err).ToNot(HaveOccurred()) Expect(found).To(BeFalse()) Expect(fakeProvider.ReapContainerCallCount()).To(Equal(1)) expiredHandle := fakeProvider.ReapContainerArgsForCall(0) Expect(expiredHandle).To(Equal("some-handle")) }) Context("when expiring the container fails", func() { disaster := errors.New("nope") BeforeEach(func() { fakeProvider.ReapContainerReturns(disaster) }) It("returns the error", func() { _, _, err := pool.LookupContainer(logger, "some-handle") Expect(err).To(Equal(disaster)) }) })