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