本文整理汇总了Golang中github.com/concourse/atc/exec/fakes.FakeArtifactSource.StreamFileReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeArtifactSource.StreamFileReturns方法的具体用法?Golang FakeArtifactSource.StreamFileReturns怎么用?Golang FakeArtifactSource.StreamFileReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/atc/exec/fakes.FakeArtifactSource
的用法示例。
在下文中一共展示了FakeArtifactSource.StreamFileReturns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var fakeArtifactSource *fakes.FakeArtifactSource
BeforeEach(func() {
fakeArtifactSource = new(fakes.FakeArtifactSource)
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() {
示例2:
path = "bogus"
})
It("returns ErrFileNotFound", func() {
Expect(streamErr).To(MatchError(FileNotFoundError{Path: "bogus"}))
})
})
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)
})