本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/system/fakes.FakeFileSystem.MkdirAll方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFileSystem.MkdirAll方法的具体用法?Golang FakeFileSystem.MkdirAll怎么用?Golang FakeFileSystem.MkdirAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.MkdirAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
BeforeEach(func() {
fs = fakesys.NewFakeFileSystem()
cmdRunner = fakesys.NewFakeCmdRunner()
runner = NewFileLoggingCmdRunner(fs, cmdRunner, "/fake-base-dir", 15)
cmd = boshsys.Command{
Name: "fake-cmd",
Args: []string{"fake-args"},
Env: map[string]string{"fake-env-key": "fake-env-var"},
WorkingDir: "/fake-working-dir",
}
})
Describe("RunCommand", func() {
It("cleans logs directory", func() {
err := fs.MkdirAll("/fake-base-dir/fake-log-dir-name/", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/fake-base-dir/fake-log-dir-name/old-file", []byte("test-data"))
Expect(err).ToNot(HaveOccurred())
_, err = runner.RunCommand("fake-log-dir-name", "fake-log-file-name", cmd)
Expect(err).ToNot(HaveOccurred())
Expect(fs.FileExists("/fake-base-dir/fake-log-dir-name/old-file")).To(BeFalse())
})
It("returns an error if it fails to remove previous logs directory", func() {
fs.RemoveAllError = errors.New("fake-remove-all-error")
_, err := runner.RunCommand("fake-log-dir-name", "fake-log-file-name", cmd)
示例2:
installPath string
enablePath string
fileBundle FileBundle
)
BeforeEach(func() {
fs = fakesys.NewFakeFileSystem()
installPath = "/install-path"
enablePath = "/enable-path"
logger = boshlog.NewLogger(boshlog.LevelNone)
fileBundle = NewFileBundle(installPath, enablePath, fs, logger)
})
createSourcePath := func() string {
path := "/source-path"
err := fs.MkdirAll(path, os.ModePerm)
Expect(err).ToNot(HaveOccurred())
return path
}
BeforeEach(func() {
sourcePath = createSourcePath()
})
Describe("Install", func() {
It("installs the bundle from source at the given path", func() {
actualFs, path, err := fileBundle.Install(sourcePath)
Expect(err).NotTo(HaveOccurred())
Expect(actualFs).To(Equal(fs))
Expect(path).To(Equal(installPath))