Пример #1
0
				repo.RegisterSource("some", fakeArtifactSource)
			})

			Context("when the artifact source provides a proper file", func() {
				var streamedOut *gbytes.Buffer

				BeforeEach(func() {
					marshalled, err := yaml.Marshal(someConfig)
					Ω(err).ShouldNot(HaveOccurred())

					streamedOut = gbytes.BufferWithBytes(marshalled)
					fakeArtifactSource.StreamFileReturns(streamedOut, nil)
				})

				It("fetches the file via the correct path", func() {
					Ω(fakeArtifactSource.StreamFileArgsForCall(0)).Should(Equal("build.yml"))
				})

				It("succeeds", func() {
					Ω(fetchErr).ShouldNot(HaveOccurred())
				})

				It("returns the unmarshalled config", func() {
					Ω(fetchedConfig).Should(Equal(someConfig))
				})

				It("closes the stream", func() {
					Ω(streamedOut.Closed()).Should(BeTrue())
				})
			})
Пример #2
0
				})

				Context("from a path referring to a source", func() {
					var outStream io.ReadCloser

					BeforeEach(func() {
						path = "first-source/foo"

						outStream = gbytes.NewBuffer()
						firstSource.StreamFileReturns(outStream, nil)
					})

					It("streams out from the source", func() {
						Ω(stream).Should(Equal(outStream))

						Ω(firstSource.StreamFileArgsForCall(0)).Should(Equal("foo"))
					})

					Context("when streaming out from the source fails", func() {
						disaster := errors.New("nope")

						BeforeEach(func() {
							firstSource.StreamFileReturns(nil, disaster)
						})

						It("returns the error", func() {
							Ω(streamErr).Should(Equal(disaster))
						})
					})
				})
			})
Пример #3
0
				})

				Context("from a path referring to a source", func() {
					var outStream io.ReadCloser

					BeforeEach(func() {
						path = "first-source/foo"

						outStream = gbytes.NewBuffer()
						firstSource.StreamFileReturns(outStream, nil)
					})

					It("streams out from the source", func() {
						Expect(stream).To(Equal(outStream))

						Expect(firstSource.StreamFileArgsForCall(0)).To(Equal("foo"))
					})

					Context("when streaming out from the source fails", func() {
						disaster := errors.New("nope")

						BeforeEach(func() {
							firstSource.StreamFileReturns(nil, disaster)
						})

						It("returns the error", func() {
							Expect(streamErr).To(Equal(disaster))
						})
					})
				})
			})
Пример #4
0
				repo.RegisterSource("some", fakeArtifactSource)
			})

			Context("when the artifact source provides a proper file", func() {
				var streamedOut *gbytes.Buffer

				BeforeEach(func() {
					marshalled, err := yaml.Marshal(someConfig)
					Expect(err).NotTo(HaveOccurred())

					streamedOut = gbytes.BufferWithBytes(marshalled)
					fakeArtifactSource.StreamFileReturns(streamedOut, nil)
				})

				It("fetches the file via the correct path", func() {
					Expect(fakeArtifactSource.StreamFileArgsForCall(0)).To(Equal("build.yml"))
				})

				It("succeeds", func() {
					Expect(fetchErr).NotTo(HaveOccurred())
				})

				It("returns the unmarshalled config", func() {
					Expect(fetchedConfig).To(Equal(someConfig))
				})

				It("closes the stream", func() {
					Expect(streamedOut.Closed()).To(BeTrue())
				})
			})