本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundle.Installed方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeBundle.Installed方法的具体用法?Golang FakeBundle.Installed怎么用?Golang FakeBundle.Installed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection/fakes.FakeBundle
的用法示例。
在下文中一共展示了FakeBundle.Installed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
//.........这里部分代码省略.........
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())
// bundle installation did not happen before decompression
Expect(installedBeforeDecompression).To(BeFalse())
// make sure that bundle install happened after decompression
Expect(bundle.InstallSourcePath).To(Equal("/fake-tmp-dir/fake-path-in-archive"))
})
It("sets executable bit for files in bin", func() {
fs.TempDirDir = "/fake-tmp-dir"
compressor.DecompressFileToDirCallBack = func() {
fs.WriteFile("/fake-tmp-dir/fake-path-in-archive/bin/test1", []byte{})
fs.WriteFile("/fake-tmp-dir/fake-path-in-archive/bin/test2", []byte{})
fs.WriteFile("/fake-tmp-dir/fake-path-in-archive/config/test", []byte{})
}
fs.SetGlob("/fake-tmp-dir/fake-path-in-archive/bin/*", []string{
"/fake-tmp-dir/fake-path-in-archive/bin/test1",
"/fake-tmp-dir/fake-path-in-archive/bin/test2",
})
var binTest1Stats, binTest2Stats, configTestStats *fakesys.FakeFileStats
bundle.InstallCallBack = func() {
binTest1Stats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/bin/test1")
binTest2Stats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/bin/test2")
configTestStats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/config/test")
示例2: init
//.........这里部分代码省略.........
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 package blob fails", func() {
compressor.DecompressFileToDirErr = errors.New("fake-decompress-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-decompress-error"))
})
It("installs bundle from decompressed tmp path of a package blob", func() {
fs.TempDirDir = "/fake-tmp-dir"
var installedBeforeDecompression bool
compressor.DecompressFileToDirCallBack = func() {
installedBeforeDecompression = bundle.Installed
}
err := act()
Expect(err).ToNot(HaveOccurred())
// bundle installation did not happen before decompression
Expect(installedBeforeDecompression).To(BeFalse())
// make sure that bundle install happened after decompression
Expect(bundle.InstallSourcePath).To(Equal("/fake-tmp-dir"))
})
}
Describe("Prepare", func() {
act := func() error { return applier.Prepare(pkg) }
It("return an error if getting file bundle fails", func() {
packagesBc.GetErr = errors.New("fake-get-bundle-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-bundle-error"))
})
It("returns an error if checking for package installation fails", func() {
bundle.IsInstalledErr = errors.New("fake-is-installed-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-is-installed-error"))
})