本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.RegisterMkdirAllError方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFileSystem.RegisterMkdirAllError方法的具体用法?Golang FakeFileSystem.RegisterMkdirAllError怎么用?Golang FakeFileSystem.RegisterMkdirAllError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.RegisterMkdirAllError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
//.........这里部分代码省略.........
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-remove-error"))
})
It("returns an error if creating compile target directory during uncompression fails", func() {
fs.RemoveAllStub = func(path string) error {
if path == "/fake-compile-dir/pkg_name" {
return errors.New("fake-mkdir-error")
}
return nil
}
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdir-error"))
})
It("returns an error if removing temporary compile target directory during uncompression fails", func() {
fs.RemoveAllStub = func(path string) error {
if path == "/fake-compile-dir/pkg_name-bosh-agent-unpack" {
return errors.New("fake-remove-error")
}
return nil
}
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-remove-error"))
})
It("returns an error if creating temporary compile target directory during uncompression fails", func() {
fs.RegisterMkdirAllError("/fake-compile-dir/pkg_name-bosh-agent-unpack", errors.New("fake-mkdir-error"))
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdir-error"))
})
It("returns an error if target directory is empty during uncompression", func() {
pkg.BlobstoreID = ""
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Blobstore ID for package '%s' is empty", pkg.Name))
})
It("installs dependent packages", func() {
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).ToNot(HaveOccurred())
Expect(packageApplier.AppliedPackages).To(Equal(pkgDeps))
})
It("cleans up the compile directory", func() {
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).ToNot(HaveOccurred())
Expect(fs.FileExists("/fake-compile-dir/pkg_name")).To(BeFalse())
})
It("installs, enables and later cleans up bundle", func() {
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).ToNot(HaveOccurred())
Expect(bundle.ActionsCalled).To(Equal([]string{
"InstallWithoutContents",
"Enable",
示例2:
Context("when saving to the compiled package repo fails", func() {
JustBeforeEach(func() {
expectSave.Return(errors.New("fake-error")).Times(1)
})
It("returns error", func() {
_, _, err := compiler.Compile(pkg)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Saving compiled package"))
Expect(err.Error()).To(ContainSubstring("fake-error"))
})
})
Context("when creating packages dir fails", func() {
JustBeforeEach(func() {
fs.RegisterMkdirAllError(installPath, errors.New("fake-error"))
})
It("returns error", func() {
_, _, err := compiler.Compile(pkg)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Creating package install dir"))
Expect(err.Error()).To(ContainSubstring("fake-error"))
})
})
Context("when finding compiled package in the repo fails", func() {
JustBeforeEach(func() {
expectFind.Return(bistatepkg.CompiledPackageRecord{}, false, errors.New("fake-error")).Times(1)
})