本文整理匯總了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))