本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.Symlink方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFileSystem.Symlink方法的具体用法?Golang FakeFileSystem.Symlink怎么用?Golang FakeFileSystem.Symlink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.Symlink方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
pathResolver = NewIDDevicePathResolver(500*time.Millisecond, udev, fs)
})
Describe("GetRealDevicePath", func() {
It("refreshes udev", func() {
pathResolver.GetRealDevicePath(diskSettings)
Expect(udev.Triggered).To(Equal(true))
Expect(udev.Settled).To(Equal(true))
})
Context("when path exists", func() {
BeforeEach(func() {
err := fs.MkdirAll("fake-device-path", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
err = fs.Symlink("fake-device-path", "/dev/disk/by-id/virtio-fake-disk-id-include")
Expect(err).ToNot(HaveOccurred())
fs.SetGlob("/dev/disk/by-id/*fake-disk-id-include", []string{"fake-device-path"})
})
It("returns the path", func() {
path, timeout, err := pathResolver.GetRealDevicePath(diskSettings)
Expect(err).ToNot(HaveOccurred())
Expect(path).To(Equal("fake-device-path"))
Expect(timeout).To(BeFalse())
})
})
Context("when disks with the same ID but different virtio prefixes exist ", func() {
示例2:
"/sys/class/scsi_host/host1/scan",
"/sys/class/scsi_host/host2/scan",
}
fs.SetGlob("/sys/class/scsi_host/host*/scan", hosts)
fs.SetGlob("/dev/disk/by-id/*"+id, []string{
"/dev/disk/by-id/scsi-3" + id,
})
})
Describe("GetRealDevicePath", func() {
Context("when path exists", func() {
BeforeEach(func() {
err := fs.MkdirAll("fake-device-path", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
err = fs.Symlink("fake-device-path", "/dev/disk/by-id/scsi-3"+id)
Expect(err).ToNot(HaveOccurred())
})
It("returns the path", func() {
path, timeout, err := pathResolver.GetRealDevicePath(diskSettings)
Expect(err).ToNot(HaveOccurred())
Expect(path).To(Equal("fake-device-path"))
Expect(timeout).To(BeFalse())
for _, host := range hosts {
str, _ := fs.ReadFileString(host)
Expect(str).To(Equal("- - -"))
}
})
示例3:
"/sys/bus/vmbus/devices/vmbus_0_12/device_id",
"/sys/bus/vmbus/devices/vmbus_12/device_id",
})
})
Describe("GetRealDevicePath", func() {
Context("when path exists", func() {
BeforeEach(func() {
deviceIDPath := "/sys/bus/vmbus/devices/fake-vmbus-device/device_id"
err := fs.WriteFileString(deviceIDPath, "fake-host-device-id")
Expect(err).ToNot(HaveOccurred())
err = fs.MkdirAll("fake-root/fake-vmbus-device/fake-base", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
err = fs.Symlink("fake-root/fake-vmbus-device/fake-base", "/sys/class/block/sdc")
Expect(err).ToNot(HaveOccurred())
err = fs.MkdirAll("/dev/sdc", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
})
It("returns the real path", func() {
path, timeout, err := pathResolver.GetRealDevicePath(diskSettings)
Expect(err).ToNot(HaveOccurred())
Expect(path).To(Equal("/dev/sdc"))
Expect(timeout).To(BeFalse())
for _, host := range hosts {
str, _ := fs.ReadFileString(host)
示例4: describeUbuntuNetManager
//.........这里部分代码省略.........
Context("when writing to ../resolv.conf.d/base fails", func() {
It("fails reporting the error", func() {
fs.WriteFileError = errors.New("fake-write-file-error")
err := netManager.SetupNetworking(networks, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Writing to /etc/resolvconf/resolv.conf.d/base"))
})
})
})
Context("when no DNS servers are configured", func() {
BeforeEach(func() {
dhcpNetwork.DNS = []string{}
networks = boshsettings.Networks{
"first": dhcpNetwork,
"second": staticNetwork,
}
})
Context("when could not read link /etc/resolv.conf", func() {
It("fails reporting error", func() {
fs.ReadLinkError = errors.New("fake-read-link-error")
err := netManager.SetupNetworking(networks, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Reading /etc/resolv.conf symlink"))
})
})
Context("when /etc/resolv.conf is no symlink", func() {
BeforeEach(func() {
err := fs.Symlink("/etc/resolv.conf", "/etc/resolv.conf")
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFileString("/etc/resolv.conf", "fake-content")
Expect(err).ToNot(HaveOccurred())
})
It("copies /etc/resolv.conf to .../resolv.conf.d/base", func() {
err := netManager.SetupNetworking(networks, nil)
Expect(err).ToNot(HaveOccurred())
contents, err := fs.ReadFile("/etc/resolvconf/resolv.conf.d/base")
Expect(err).ToNot(HaveOccurred())
Expect(string(contents)).To(Equal("fake-content"))
})
Context("when copying fails", func() {
It("fails reporting the error", func() {
fs.CopyFileError = errors.New("fake-copy-error")
err := netManager.SetupNetworking(networks, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Copying /etc/resolv.conf for backwards compat"))
})
})
})
})
It("forces /etc/resolv.conf to be a symlink", func() {
err := netManager.SetupNetworking(networks, nil)
Expect(err).ToNot(HaveOccurred())
Expect(fs.ReadLink("/etc/resolv.conf")).To(Equal("/run/resolvconf/resolv.conf"))
})
示例5:
}
})
Describe("GetRealDevicePath", func() {
It("refreshes udev", func() {
pathResolver.GetRealDevicePath(diskSettings)
Expect(udev.Triggered).To(Equal(true))
Expect(udev.Settled).To(Equal(true))
})
Context("when path exists", func() {
BeforeEach(func() {
err := fs.MkdirAll("fake-device-path", os.FileMode(0750))
Expect(err).ToNot(HaveOccurred())
err = fs.Symlink("fake-device-path", "/dev/disk/by-id/virtio-fake-disk-id-include")
Expect(err).ToNot(HaveOccurred())
})
It("returns the path ", func() {
path, timeout, err := pathResolver.GetRealDevicePath(diskSettings)
Expect(err).ToNot(HaveOccurred())
Expect(path).To(Equal("fake-device-path"))
Expect(timeout).To(BeFalse())
})
})
Context("when path does not exist", func() {
BeforeEach(func() {
err := fs.Symlink("fake-device-path", "/dev/disk/by-id/virtio-fake-disk-id-include")