本文整理匯總了Golang中bosh/platform/fakes.FakePlatform.GetFileContentsFromCDROMContents方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePlatform.GetFileContentsFromCDROMContents方法的具體用法?Golang FakePlatform.GetFileContentsFromCDROMContents怎麽用?Golang FakePlatform.GetFileContentsFromCDROMContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/platform/fakes.FakePlatform
的用法示例。
在下文中一共展示了FakePlatform.GetFileContentsFromCDROMContents方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("Testing with Ginkgo", func() {
var (
vsphere Infrastructure
platform *fakeplatform.FakePlatform
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
})
JustBeforeEach(func() {
vsphere = NewVsphereInfrastructure(platform)
})
It("vsphere get settings", func() {
platform.GetFileContentsFromCDROMContents = []byte(`{"agent_id": "123"}`)
settings, err := vsphere.GetSettings()
Expect(err).NotTo(HaveOccurred())
Expect(platform.GetFileContentsFromCDROMPath).To(Equal("env"))
Expect(settings.AgentId).To(Equal("123"))
})
It("vsphere setup networking", func() {
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
vsphere.SetupNetworking(networks)
Expect(platform.SetupManualNetworkingNetworks).To(Equal(networks))
})
It("vsphere get ephemeral disk path", func() {
platform.NormalizeDiskPathRealPath = "/dev/sdb"
platform.NormalizeDiskPathFound = true
realPath, found := vsphere.GetEphemeralDiskPath("does not matter")
Expect(found).To(Equal(true))
Expect(realPath).To(Equal("/dev/sdb"))
Expect(platform.NormalizeDiskPathPath).To(Equal("/dev/sdb"))
})
})
}
示例2:
devicePathResolver *fakedpresolv.FakeDevicePathResolver
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
devicePathResolver = fakedpresolv.NewFakeDevicePathResolver()
logger = boshlog.NewLogger(boshlog.LevelNone)
})
JustBeforeEach(func() {
vsphere = NewVsphereInfrastructure(platform, devicePathResolver, logger)
})
Describe("GetSettings", func() {
It("vsphere get settings", func() {
platform.GetFileContentsFromCDROMContents = []byte(`{"agent_id": "123"}`)
settings, err := vsphere.GetSettings()
Expect(err).NotTo(HaveOccurred())
Expect(platform.GetFileContentsFromCDROMPath).To(Equal("env"))
Expect(settings.AgentID).To(Equal("123"))
})
})
Describe("SetupNetworking", func() {
It("vsphere setup networking", func() {
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
vsphere.SetupNetworking(networks)
示例3: init
func init() {
Describe("vSphere Infrastructure", func() {
var (
logger boshlog.Logger
vsphere Infrastructure
platform *fakeplatform.FakePlatform
fakeDevicePathResolver *fakedpresolv.FakeDevicePathResolver
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
fakeDevicePathResolver = fakedpresolv.NewFakeDevicePathResolver(1*time.Millisecond, platform.GetFs())
logger = boshlog.NewLogger(boshlog.LevelNone)
})
JustBeforeEach(func() {
vsphere = NewVsphereInfrastructure(platform, fakeDevicePathResolver, logger)
})
Describe("GetSettings", func() {
It("vsphere get settings", func() {
platform.GetFileContentsFromCDROMContents = []byte(`{"agent_id": "123"}`)
settings, err := vsphere.GetSettings()
Expect(err).NotTo(HaveOccurred())
Expect(platform.GetFileContentsFromCDROMPath).To(Equal("env"))
Expect(settings.AgentID).To(Equal("123"))
})
})
Describe("SetupNetworking", func() {
It("vsphere setup networking", func() {
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
vsphere.SetupNetworking(networks)
Expect(platform.SetupManualNetworkingNetworks).To(Equal(networks))
})
})
Describe("GetEphemeralDiskPath", func() {
It("vsphere get ephemeral disk path", func() {
realPath, found := vsphere.GetEphemeralDiskPath("does not matter")
Expect(found).To(Equal(true))
Expect(realPath).To(Equal("/dev/sdb"))
})
})
Describe("MountPersistentDisk", func() {
BeforeEach(func() {
fakeDevicePathResolver.RealDevicePath = "fake-real-device-path"
})
It("creates the mount directory with the correct permissions", func() {
vsphere.MountPersistentDisk("fake-volume-id", "/mnt/point")
mountPoint := platform.Fs.GetFileTestStat("/mnt/point")
Expect(mountPoint.FileType).To(Equal(fakesys.FakeFileTypeDir))
Expect(mountPoint.FileMode).To(Equal(os.FileMode(0700)))
})
It("partitions the disk", func() {
vsphere.MountPersistentDisk("fake-volume-id", "/mnt/point")
Expect(platform.FakeDiskManager.FakePartitioner.PartitionDevicePath).To(Equal("fake-real-device-path"))
partitions := []boshdisk.Partition{
{Type: boshdisk.PartitionTypeLinux},
}
Expect(platform.FakeDiskManager.FakePartitioner.PartitionPartitions).To(Equal(partitions))
})
It("formats the disk", func() {
vsphere.MountPersistentDisk("fake-volume-id", "/mnt/point")
Expect(platform.FakeDiskManager.FakeFormatter.FormatPartitionPaths).To(Equal([]string{"fake-real-device-path1"}))
Expect(platform.FakeDiskManager.FakeFormatter.FormatFsTypes).To(Equal([]boshdisk.FileSystemType{boshdisk.FileSystemExt4}))
})
It("mounts the disk", func() {
vsphere.MountPersistentDisk("fake-volume-id", "/mnt/point")
Expect(platform.FakeDiskManager.FakeMounter.MountPartitionPaths).To(Equal([]string{"fake-real-device-path1"}))
Expect(platform.FakeDiskManager.FakeMounter.MountMountPoints).To(Equal([]string{"/mnt/point"}))
})
})
})
}