本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/fileutil/fakes.FakeCompressor.DecompressFileToDirCallBack方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeCompressor.DecompressFileToDirCallBack方法的具体用法?Golang FakeCompressor.DecompressFileToDirCallBack怎么用?Golang FakeCompressor.DecompressFileToDirCallBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-utils/fileutil/fakes.FakeCompressor
的用法示例。
在下文中一共展示了FakeCompressor.DecompressFileToDirCallBack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
//.........这里部分代码省略.........
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 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"))
})
示例2: init
//.........这里部分代码省略.........
})
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",
"Disable",
"Uninstall",
}))
})
It("returns an error if removing the compile directory fails", func() {
callCount := 0
fs.RemoveAllStub = func(path string) error {
if path == "/fake-compile-dir/pkg_name" {
callCount++
if callCount > 1 {
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"))
})
Context("when packaging script exists", func() {
const packagingScriptContents = "hi"
BeforeEach(func() {
compressor.DecompressFileToDirCallBack = func() {
filename := "/fake-compile-dir/pkg_name/" + PackagingScriptName
fs.WriteFileString(filename, packagingScriptContents)
}
})
It("runs packaging script ", func() {
_, _, err := compiler.Compile(pkg, pkgDeps)
Expect(err).ToNot(HaveOccurred())
expectedCmd := boshsys.Command{
Env: map[string]string{
"BOSH_COMPILE_TARGET": "/fake-compile-dir/pkg_name",
"BOSH_INSTALL_TARGET": "/fake-dir/packages/pkg_name",
"BOSH_PACKAGE_NAME": "pkg_name",
"BOSH_PACKAGE_VERSION": "pkg_version",
},
WorkingDir: "/fake-compile-dir/pkg_name",
}
cmd := runner.RunCommands[0]
if runtime.GOOS == "windows" {
expectedCmd.Name = "powershell"
expectedCmd.Args = []string{"-command", fmt.Sprintf(`"iex (get-content -raw %s)"`, PackagingScriptName)}
} else {
expectedCmd.Name = "bash"
expectedCmd.Args = []string{"-x", PackagingScriptName}
}
Expect(cmd).To(Equal(expectedCmd))
Expect(len(runner.RunCommands)).To(Equal(1))
Expect(runner.RunCommandJobName).To(Equal("compilation"))
Expect(runner.RunCommandTaskName).To(Equal(PackagingScriptName))
示例3: init
//.........这里部分代码省略.........
Expect(err).ToNot(HaveOccurred())
Expect(blobstore.GetBlobIDs[0]).To(Equal("fake-blobstore-id"))
Expect(blobstore.GetFingerprints[0]).To(Equal(boshcrypto.NewDigest("sha256", "fake-blob-sha256")))
})
It("returns error when given and unsupported fingerprint", func() {
blobstore.GetFileName = "/fake-blobstore-file-name"
job.Source.Sha1 = "unsupported:checksum"
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Parsing job blob digest"))
})
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 walking the tree of files fails", func() {
fs.WalkErr = errors.New("fake-walk-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-walk-error"))
})
It("installs bundle from decompressed tmp path of a job template", func() {
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 the bin and config directories", func() {
var binDirStats, configDirStats *fakesys.FakeFileStats
compressor.DecompressFileToDirCallBack = func() {
fs.WriteFile("/fake-tmp-dir/fake-path-in-archive/bin/blarg", []byte{})
fs.WriteFile("/fake-tmp-dir/fake-path-in-archive/config/blarg.yml", []byte{})
}
bundle.InstallCallBack = func() {
binDirStats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/bin")
configDirStats = fs.GetFileTestStat("/fake-tmp-dir/fake-path-in-archive/config")
}
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(int(binDirStats.FileMode)).To(Equal(0755))
Expect(int(configDirStats.FileMode)).To(Equal(0755))
})