本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/system/fakes.FakeFileSystem.GlobErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.GlobErr方法的具體用法?Golang FakeFileSystem.GlobErr怎麽用?Golang FakeFileSystem.GlobErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.GlobErr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
tmpDirExistsBeforeInstall = true
}
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(compressor.DecompressFileToDirTarballPaths[0]).To(Equal("/fake-blobstore-file-name"))
Expect(compressor.DecompressFileToDirDirs[0]).To(Equal("/fake-tmp-dir"))
// tmp dir exists before bundle install
Expect(tmpDirExistsBeforeInstall).To(BeTrue())
// tmp dir is cleaned up after install
Expect(fs.FileExists(fs.TempDirDir)).To(BeFalse())
})
It("returns error when temporary directory creation fails", func() {
fs.TempDirError = errors.New("fake-filesystem-tempdir-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-filesystem-tempdir-error"))
})
It("returns error when decompressing job template fails", func() {
compressor.DecompressFileToDirErr = errors.New("fake-decompress-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-decompress-error"))
})
It("returns error when getting the list of bin files fails", func() {
fs.GlobErr = errors.New("fake-glob-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-glob-error"))
})
It("returns error when changing permissions on bin files fails", func() {
fs.TempDirDir = "/fake-tmp-dir"
fs.SetGlob("/fake-tmp-dir/fake-path-in-archive/bin/*", []string{
"/fake-tmp-dir/fake-path-in-archive/bin/test",
})
fs.ChmodErr = errors.New("fake-chmod-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-chmod-error"))
})
It("installs bundle from decompressed tmp path of a job template", func() {
fs.TempDirDir = "/fake-tmp-dir"
var installedBeforeDecompression bool
compressor.DecompressFileToDirCallBack = func() {
installedBeforeDecompression = bundle.Installed
}
err := act()
Expect(err).ToNot(HaveOccurred())
示例2:
fs,
logger,
),
NewFileBundle(
installPath+"/fake-bundle-2-name/fake-bundle-2-version-1",
enablePath+"/fake-bundle-2-name",
fs,
logger,
),
}
Expect(bundles).To(Equal(expectedBundles))
})
It("returns error when glob fails to execute", func() {
fs.GlobErr = errors.New("fake-glob-error")
_, err := fileBundleCollection.List()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-glob-error"))
})
It("returns error when bundle cannot be built from matched path", func() {
invalidPaths := []string{
"",
"/",
"before-slash/",
"/after-slash",
"no-slash",
}