本文整理匯總了Golang中github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/fileutil/fakes.FakeCompressor.DecompressFileToDirErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeCompressor.DecompressFileToDirErr方法的具體用法?Golang FakeCompressor.DecompressFileToDirErr怎麽用?Golang FakeCompressor.DecompressFileToDirErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/fileutil/fakes.FakeCompressor
的用法示例。
在下文中一共展示了FakeCompressor.DecompressFileToDirErr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Fingerprint: "fake-job-fingerprint",
SHA1: "fake-job-sha",
ExtractedPath: "/extracted/release/extracted_jobs/fake-job",
Templates: map[string]string{"some_template": "some_file"},
PackageNames: []string{"fake-package"},
Packages: []*birelpkg.Package{expectedPackage},
Properties: map[string]bireljob.PropertyDefinition{},
},
}))
Expect(release.Packages()).To(Equal([]*birelpkg.Package{expectedPackage}))
})
})
Context("when the package cannot be extracted", func() {
BeforeEach(func() {
compressor.DecompressFileToDirErr = errors.New("Extracting package 'fake-package'")
})
It("returns errors for each invalid package", func() {
_, err := reader.Read()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Extracting package 'fake-package'"))
})
})
})
Context("when the jobs in the release are not valid", func() {
BeforeEach(func() {
fakeFs.WriteFileString(
"/extracted/release/release.MF",
`---
示例2:
err := extractor.Extract(blobID, blobSHA1, targetDir)
Expect(err).ToNot(HaveOccurred())
Expect(fs.FileExists(targetDir)).To(BeTrue())
Expect(compressor.DecompressFileToDirTarballPaths).To(ContainElement(fileName))
})
It("does not re-create the target package dir", func() {
fs.MkdirAllError = fakeError
err := extractor.Extract(blobID, blobSHA1, targetDir)
Expect(err).ToNot(HaveOccurred())
})
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() {
示例3:
})
Context("when the job manifest is invalid", func() {
It("returns an error when the job manifest is missing", func() {
_, err := reader.Read()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Reading job manifest"))
})
It("returns an error when the job manifest is invalid", func() {
fakeFs.WriteFileString("/extracted/job/job.MF", "{")
_, err := reader.Read()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Parsing job manifest"))
})
})
})
Context("when the job archive is not a valid tar", func() {
BeforeEach(func() {
compressor.DecompressFileToDirErr = bosherr.Error("fake-error")
})
It("returns error", func() {
_, err := reader.Read()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Extracting job archive '/some/job/archive'"))
})
})
})