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