本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter.MountErr方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeMounter.MountErr方法的具体用法?Golang FakeMounter.MountErr怎么用?Golang FakeMounter.MountErr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter
的用法示例。
在下文中一共展示了FakeMounter.MountErr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var _ = Describe("linuxBindMounter", func() {
var (
delegateErr error
delegateMounter *fakedisk.FakeMounter
mounter Mounter
)
BeforeEach(func() {
delegateErr = errors.New("fake-err")
delegateMounter = &fakedisk.FakeMounter{}
mounter = NewLinuxBindMounter(delegateMounter)
})
Describe("Mount", func() {
It("delegates to mounter and adds --bind option to mount as a bind-mount", func() {
delegateMounter.MountErr = delegateErr
err := mounter.Mount("fake-partition-path", "fake-mount-path", "fake-opt1")
// Outputs
Expect(err).To(Equal(delegateErr))
// Inputs
Expect(delegateMounter.MountPartitionPaths).To(Equal([]string{"fake-partition-path"}))
Expect(delegateMounter.MountMountPoints).To(Equal([]string{"fake-mount-path"}))
Expect(delegateMounter.MountMountOptions).To(Equal([][]string{{"fake-opt1", "--bind"}}))
})
})
Describe("RemountAsReadonly", func() {
It("does not delegate to mounter because remount with --bind does not work", func() {
示例2: describeLinuxPlatform
//.........这里部分代码省略.........
Expect(sysStats.SymlinkTarget).To(Equal("/fake-dir/data/sys"))
})
It("creates new sys/run dir", func() {
err := platform.SetupDataDir()
Expect(err).NotTo(HaveOccurred())
sysRunStats := fs.GetFileTestStat("/fake-dir/data/sys/run")
Expect(sysRunStats).ToNot(BeNil())
Expect(sysRunStats.FileType).To(Equal(fakesys.FakeFileTypeDir))
Expect(sysRunStats.FileMode).To(Equal(os.FileMode(0750)))
Expect(cmdRunner.RunCommands[2]).To(Equal([]string{"chown", "root:vcap", "/fake-dir/data/sys/run"}))
})
It("mounts tmpfs to sys/run", func() {
err := platform.SetupDataDir()
Expect(err).NotTo(HaveOccurred())
Expect(len(mounter.MountPartitionPaths)).To(Equal(1))
Expect(mounter.MountPartitionPaths[0]).To(Equal("tmpfs"))
Expect(mounter.MountMountPoints[0]).To(Equal("/fake-dir/data/sys/run"))
Expect(mounter.MountMountOptions[0]).To(Equal([]string{"-t", "tmpfs", "-o", "size=1m"}))
})
It("returns an error if creation of mount point fails", func() {
fs.MkdirAllError = errors.New("fake-mkdir-error")
err := platform.SetupDataDir()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdir-error"))
})
It("returns an error if mounting tmpfs fails", func() {
mounter.MountErr = errors.New("fake-mount-error")
err := platform.SetupDataDir()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mount-error"))
})
})
})
Describe("SetupTmpDir", func() {
act := func() error { return platform.SetupTmpDir() }
var mounter *fakedisk.FakeMounter
BeforeEach(func() {
mounter = diskManager.FakeMounter
})
It("changes permissions on /tmp", func() {
err := act()
Expect(err).NotTo(HaveOccurred())
Expect(cmdRunner.RunCommands[0]).To(Equal([]string{"chown", "root:vcap", "/tmp"}))
Expect(cmdRunner.RunCommands[1]).To(Equal([]string{"chmod", "0770", "/tmp"}))
Expect(cmdRunner.RunCommands[2]).To(Equal([]string{"chmod", "0700", "/var/tmp"}))
})
It("creates new temp dir", func() {
err := act()
Expect(err).NotTo(HaveOccurred())
fileStats := fs.GetFileTestStat("/fake-dir/data/tmp")
Expect(fileStats).NotTo(BeNil())
Expect(fileStats.FileType).To(Equal(fakesys.FakeFileType(fakesys.FakeFileTypeDir)))
示例3:
_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
Expect(err).ToNot(HaveOccurred())
Expect(fs.FileExists("fake-tempdir")).To(BeFalse())
})
It("returns error if it fails to create temporary mount directory", func() {
fs.TempDirError = errors.New("fake-tempdir-error")
_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-tempdir-error"))
})
It("returns error if it fails to mount disk path", func() {
mounter.MountErr = errors.New("fake-mount-error")
_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mount-error"))
})
It("returns an error if it fails to read the file", func() {
fs.ReadFileError = errors.New("fake-read-error")
_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-read-error"))
})
It("returns error if it fails to unmount disk path", func() {
mounter.UnmountErr = errors.New("fake-unmount-error")