本文整理汇总了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") }
开发者ID:guoger,项目名称:bosh-agent,代码行数:66,代码来源:linux_platform_test.go
示例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")
开发者ID:mattcui,项目名称:bosh-agent,代码行数:30,代码来源:linux_bind_mounter_test.go
示例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())
开发者ID:viovanov,项目名称:bosh-agent,代码行数:30,代码来源:diskutil_test.go
注:本文中的github.com/cloudfoundry/bosh-agent/platform/disk/fakes.FakeMounter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论