Exemple #1
0
					fakeTracker.InitWithSourcesStub = func(lager.Logger, resource.Metadata, resource.Session, resource.ResourceType, atc.Tags, map[string]resource.ArtifactSource, atc.ResourceTypes, worker.ImageFetchingDelegate) (resource.Resource, []string, error) {
						callCountDuringInit <- putDelegate.InitializingCallCount()
						return fakeResource, []string{"some-source", "some-other-source"}, nil
					}
				})

				It("calls the Initializing method on the delegate", func() {
					Expect(<-callCountDuringInit).To(Equal(1))
				})
			})

			Describe("releasing", func() {
				It("releases the resource with a ttl of 5 minutes", func() {
					<-process.Wait()

					Expect(fakeResource.ReleaseCallCount()).To(BeZero())

					step.Release()
					Expect(fakeResource.ReleaseCallCount()).To(Equal(1))
					Expect(fakeResource.ReleaseArgsForCall(0)).To(Equal(worker.FinalTTL(5 * time.Minute)))
				})
			})

			Describe("signalling", func() {
				var receivedSignals <-chan os.Signal

				BeforeEach(func() {
					sigs := make(chan os.Signal)
					receivedSignals = sigs

					fakeVersionedSource.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
					It("is not successful", func() {
						Eventually(process.Wait()).Should(Receive(BeNil()))
						Ω(getDelegate.CompletedCallCount()).Should(Equal(1))

						var success Success

						Ω(step.Result(&success)).Should(BeTrue())
						Ω(bool(success)).Should(BeFalse())
					})
				})
			})

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

					err := step.Release()
					Ω(err).ShouldNot(HaveOccurred())

					Ω(fakeResource.ReleaseCallCount()).Should(Equal(1))
				})
			})

			Describe("the source registered with the repository", func() {
				var artifactSource ArtifactSource

				JustBeforeEach(func() {
					Eventually(process.Wait()).Should(Receive(BeNil()))

					var found bool