本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.MkdirAllError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.MkdirAllError方法的具體用法?Golang FakeFileSystem.MkdirAllError怎麽用?Golang FakeFileSystem.MkdirAllError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.MkdirAllError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: describeLinuxPlatform
//.........這裏部分代碼省略.........
BeforeEach(func() {
partitioner = diskManager.FakePartitioner
formatter = diskManager.FakeFormatter
mounter = diskManager.FakeMounter
})
itSetsUpEphemeralDisk := func(act func() error) {
It("sets up ephemeral disk with path", func() {
err := act()
Expect(err).NotTo(HaveOccurred())
dataDir := fs.GetFileTestStat("/fake-dir/data")
Expect(dataDir.FileType).To(Equal(fakesys.FakeFileTypeDir))
Expect(dataDir.FileMode).To(Equal(os.FileMode(0750)))
})
It("creates new partition even if the data directory is not empty", func() {
fs.SetGlob(path.Join("/fake-dir", "data", "*"), []string{"something"})
err := act()
Expect(err).ToNot(HaveOccurred())
Expect(partitioner.PartitionCalled).To(BeTrue())
Expect(formatter.FormatCalled).To(BeTrue())
Expect(mounter.MountCalled).To(BeTrue())
})
}
Context("when ephemeral disk path is provided", func() {
act := func() error { return platform.SetupEphemeralDiskWithPath("/dev/xvda") }
itSetsUpEphemeralDisk(act)
It("returns error if creating data dir fails", func() {
fs.MkdirAllError = errors.New("fake-mkdir-all-err")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdir-all-err"))
Expect(partitioner.PartitionCalled).To(BeFalse())
Expect(formatter.FormatCalled).To(BeFalse())
Expect(mounter.MountCalled).To(BeFalse())
})
It("returns err when the data directory cannot be globbed", func() {
fs.GlobErr = errors.New("fake-glob-err")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Globbing ephemeral disk mount point `/fake-dir/data/*'"))
Expect(err.Error()).To(ContainSubstring("fake-glob-err"))
Expect(partitioner.PartitionCalled).To(BeFalse())
Expect(formatter.FormatCalled).To(BeFalse())
Expect(mounter.MountCalled).To(BeFalse())
})
It("returns err when mem stats are unavailable", func() {
collector.MemStatsErr = errors.New("fake-memstats-error")
err := act()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Calculating partition sizes"))
Expect(err.Error()).To(ContainSubstring("fake-memstats-error"))
Expect(partitioner.PartitionCalled).To(BeFalse())
Expect(formatter.FormatCalled).To(BeFalse())
Expect(mounter.MountCalled).To(BeFalse())
})
示例2:
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))
Expect(fs.RenameOldPaths[0]).To(Equal(sourcePath))
Expect(fs.RenameNewPaths[0]).To(Equal(installPath))
})
It("returns an error if creation of parent directory fails", func() {
fs.MkdirAllError = errors.New("fake-mkdir-error")
_, _, err := fileBundle.Install(sourcePath)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdir-error"))
})
It("sets correct permissions on install path", func() {
fs.Chmod(sourcePath, os.FileMode(0700))
_, _, err := fileBundle.Install(sourcePath)
Expect(err).NotTo(HaveOccurred())
fileStats := fs.GetFileTestStat(installPath)
Expect(fileStats).ToNot(BeNil())
Expect(fileStats.FileType).To(Equal(fakesys.FakeFileType(fakesys.FakeFileTypeDir)))