本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.Readlink方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.Readlink方法的具體用法?Golang FakeFileSystem.Readlink怎麽用?Golang FakeFileSystem.Readlink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.Readlink方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: describeUbuntuNetManager
//.........這裏部分代碼省略.........
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())
linkContents, err := fs.Readlink("/etc/resolv.conf")
Expect(err).ToNot(HaveOccurred())
Expect(linkContents).To(Equal("/run/resolvconf/resolv.conf"))
})
Context("when symlink command fails", func() {
BeforeEach(func() {
fs.SymlinkError = errors.New("fake-symlink-error")
})
It("fails reporting error", func() {
err := netManager.SetupNetworking(networks, nil)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Setting up /etc/resolv.conf symlink"))
})
})
It("writes dns servers in /etc/resolvconf/resolv.conf.d/base", func() {
dhcpNetwork.Preconfigured = true
staticNetwork.Preconfigured = true
networks := boshsettings.Networks{
"first": dhcpNetwork,
"second": staticNetwork,
}
Expect(networks.IsPreconfigured()).To(BeTrue())
err := netManager.SetupNetworking(networks, nil)
Expect(err).ToNot(HaveOccurred())
resolvConfHead := fs.GetFileTestStat("/etc/resolvconf/resolv.conf.d/base")
Expect(resolvConfHead).ToNot(BeNil())