本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter类的典型用法代码示例。如果您正苦于以下问题:Golang FakeMounter类的具体用法?Golang FakeMounter怎么用?Golang FakeMounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeMounter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: describeLinuxPlatform
//.........这里部分代码省略.........
platform.SetupLogrotate("fake-group-name", "fake-base-path", "fake-size")
logrotateFileContent, err := fs.ReadFileString("/etc/logrotate.d/fake-group-name")
Expect(err).NotTo(HaveOccurred())
Expect(logrotateFileContent).To(Equal(expectedEtcLogrotate))
})
})
Describe("SetTimeWithNtpServers", func() {
It("sets time with ntp servers", func() {
platform.SetTimeWithNtpServers([]string{"0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"})
ntpConfig := fs.GetFileTestStat("/fake-dir/bosh/etc/ntpserver")
Expect(ntpConfig.StringContents()).To(Equal("0.north-america.pool.ntp.org 1.north-america.pool.ntp.org"))
Expect(ntpConfig.FileType).To(Equal(fakesys.FakeFileTypeFile))
Expect(len(cmdRunner.RunCommands)).To(Equal(1))
Expect(cmdRunner.RunCommands[0]).To(Equal([]string{"ntpdate"}))
})
It("sets time with ntp servers is noop when no ntp server provided", func() {
platform.SetTimeWithNtpServers([]string{})
Expect(len(cmdRunner.RunCommands)).To(Equal(0))
ntpConfig := fs.GetFileTestStat("/fake-dir/bosh/etc/ntpserver")
Expect(ntpConfig).To(BeNil())
})
})
Describe("SetupEphemeralDiskWithPath", func() {
var (
partitioner *fakedisk.FakePartitioner
formatter *fakedisk.FakeFormatter
mounter *fakedisk.FakeMounter
)
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") }
示例2:
package disk_test
import (
"errors"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/bosh-agent/platform/disk"
fakedisk "github.com/cloudfoundry/bosh-agent/platform/disk/fakes"
)
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")
示例3:
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/ginkgo"
. "github.com/cloudfoundry/bosh-agent/internal/github.com/onsi/gomega"
boshlog "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/logger"
fakesys "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes"
boshdevutil "github.com/cloudfoundry/bosh-agent/platform/deviceutil"
fakedisk "github.com/cloudfoundry/bosh-agent/platform/disk/fakes"
. "github.com/cloudfoundry/bosh-agent/platform/disk"
)
var _ = Describe("Diskutil", func() {
var (
diskUtil boshdevutil.DeviceUtil
mounter *fakedisk.FakeMounter
fs *fakesys.FakeFileSystem
)
BeforeEach(func() {
mounter = &fakedisk.FakeMounter{}
fs = fakesys.NewFakeFileSystem()
logger := boshlog.NewLogger(boshlog.LevelNone)
diskUtil = NewDiskUtil("fake-disk-path", mounter, fs, logger)
})
Describe("GetFileContents", func() {
Context("when disk path does not exist", func() {
It("returns an error if diskpath does not exist", func() {
_, err := diskUtil.GetFilesContents([]string{"fake-file-path-1"})
Expect(err).To(HaveOccurred())