当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeBlobstore.GetError方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/blobstore/fakes.FakeBlobstore.GetError方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeBlobstore.GetError方法的具体用法?Golang FakeBlobstore.GetError怎么用?Golang FakeBlobstore.GetError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/blobstore/fakes.FakeBlobstore的用法示例。


在下文中一共展示了FakeBlobstore.GetError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

			Expect(innerBlobstore.GetBlobIDs).To(Equal([]string{"fake-blob-id"}))
			Expect(fileName).To(Equal(fixturePath))
		})

		It("returns error if sha1 does not match", func() {
			innerBlobstore.GetFileName = fixturePath
			incorrectSha1 := "some-incorrect-sha1"

			_, err := sha1VerifiableBlobstore.Get("fake-blob-id", incorrectSha1)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("SHA1 mismatch"))
		})

		It("returns error if inner blobstore getting fails", func() {
			innerBlobstore.GetError = errors.New("fake-get-error")

			_, err := sha1VerifiableBlobstore.Get("fake-blob-id", fixtureSHA1)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("fake-get-error"))
		})

		It("skips sha1 verification and returns without an error if sha1 is empty", func() {
			innerBlobstore.GetFileName = fixturePath

			fileName, err := sha1VerifiableBlobstore.Get("fake-blob-id", "")
			Expect(err).ToNot(HaveOccurred())

			Expect(fileName).To(Equal(fixturePath))
		})
	})
开发者ID:vestel,项目名称:bosh-init,代码行数:30,代码来源:sha1_verifiable_blobstore_test.go

示例2:

				Context("and decompressing the blob fails", func() {
					It("returns an error and doesn't remove the target dir", func() {
						compressor.DecompressFileToDirErr = fakeError
						Expect(fs.FileExists(targetDir)).To(BeTrue())
						err := extractor.Extract(blobID, blobSHA1, targetDir)
						Expect(err).To(HaveOccurred())
						Expect(err.Error()).To(Equal("Decompressing compiled package: BlobID: 'fake-blob-id', BlobSHA1: 'fake-sha1': Initial error"))
						Expect(fs.FileExists(targetDir)).To(BeTrue())
					})
				})
			})

			Context("when getting the blob from the blobstore errors", func() {
				BeforeEach(func() {
					blobstore.GetError = fakeError
				})

				It("returns an error", func() {
					err := extractor.Extract(blobID, blobSHA1, targetDir)
					Expect(err).To(HaveOccurred())
					Expect(err.Error()).To(Equal("Getting object from blobstore: fake-blob-id: Initial error"))
				})
			})

			Context("when creating the target dir fails", func() {
				It("return an error", func() {
					fs.MkdirAllError = fakeError
					err := extractor.Extract(blobID, blobSHA1, targetDir)
					Expect(err).To(HaveOccurred())
					Expect(err.Error()).To(Equal("Creating target dir: fake-target-dir: Initial error"))
开发者ID:vestel,项目名称:bosh-init,代码行数:30,代码来源:extractor_test.go


注:本文中的github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/blobstore/fakes.FakeBlobstore.GetError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。