本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.SymlinkError方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFileSystem.SymlinkError方法的具体用法?Golang FakeFileSystem.SymlinkError怎么用?Golang FakeFileSystem.SymlinkError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.SymlinkError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("returns error", func() {
_, _, err := fileBundle.Install(sourcePath)
Expect(err).NotTo(HaveOccurred())
fs.MkdirAllError = errors.New("fake-mkdirall-error")
_, _, err = fileBundle.Enable()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-mkdirall-error"))
})
})
Context("when bundle cannot be enabled", func() {
It("returns error", func() {
_, _, err := fileBundle.Install(sourcePath)
Expect(err).NotTo(HaveOccurred())
fs.SymlinkError = errors.New("fake-symlink-error")
_, _, err = fileBundle.Enable()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-symlink-error"))
})
})
})
Describe("Disable", func() {
It("is idempotent", func() {
err := fileBundle.Disable()
Expect(err).NotTo(HaveOccurred())
err = fileBundle.Disable()
Expect(err).NotTo(HaveOccurred())
示例2: describeCentosNetManager
//.........这里部分代码省略.........
send host-name "<hostname>";
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
`))
dhcpConfigSymlink := fs.GetFileTestStat("/etc/dhcp/dhclient-ethdhcp.conf")
Expect(dhcpConfigSymlink).ToNot(BeNil())
Expect(dhcpConfigSymlink.SymlinkTarget).To(Equal("/etc/dhcp/dhclient.conf"))
})
It("returns an error if it can't write a dhcp configuration", func() {
stubInterfaces(map[string]boshsettings.Network{
"ethdhcp": dhcpNetwork,
"ethstatic": staticNetwork,
})
fs.WriteFileErrors["/etc/dhcp/dhclient.conf"] = errors.New("dhclient.conf-write-error")
err := netManager.SetupNetworking(boshsettings.Networks{"dhcp-network": dhcpNetwork, "static-network": staticNetwork}, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("dhclient.conf-write-error"))
})
It("returns an error if it can't symlink a dhcp configuration", func() {
stubInterfaces(map[string]boshsettings.Network{
"ethdhcp": dhcpNetwork,
"ethstatic": staticNetwork,
})
fs.SymlinkError = errors.New("dhclient-ethdhcp.conf-symlink-error")
err := netManager.SetupNetworking(boshsettings.Networks{"dhcp-network": dhcpNetwork, "static-network": staticNetwork}, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("dhclient-ethdhcp.conf-symlink-error"))
})
It("doesn't write a dhcp configuration if there are no dhcp networks", func() {
stubInterfaces(map[string]boshsettings.Network{
"ethstatic": staticNetwork,
})
err := netManager.SetupNetworking(boshsettings.Networks{"static-network": staticNetwork}, nil)
Expect(err).ToNot(HaveOccurred())
dhcpConfig := fs.GetFileTestStat("/etc/dhcp/dhclient-ethdhcp.conf")
Expect(dhcpConfig).To(BeNil())
})
It("restarts the networks if any ifconfig file changes", func() {
changingStaticNetwork := boshsettings.Network{
Type: "manual",
IP: "1.2.3.5",
Netmask: "255.255.255.0",
Gateway: "3.4.5.6",
Mac: "ethstatict-that-changes",
}
stubInterfaces(map[string]boshsettings.Network{
"ethdhcp": dhcpNetwork,
"ethstatic-that-changes": changingStaticNetwork,
"ethstatic": staticNetwork,
})