本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.ReadAndFollowLinkError方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeFileSystem.ReadAndFollowLinkError方法的具體用法?Golang FakeFileSystem.ReadAndFollowLinkError怎麽用?Golang FakeFileSystem.ReadAndFollowLinkError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem
的用法示例。
在下文中一共展示了FakeFileSystem.ReadAndFollowLinkError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
})
It("does not return error and does not remove the symlink", func() {
err := fileBundle.Disable()
Expect(err).NotTo(HaveOccurred())
fileStats := fs.GetFileTestStat(enablePath)
Expect(fileStats).NotTo(BeNil())
Expect(fileStats.FileType).To(Equal(fakesys.FakeFileType(fakesys.FakeFileTypeSymlink)))
Expect(newerInstallPath).To(Equal(fileStats.SymlinkTarget))
})
})
Context("when the symlink cannot be read", func() {
It("returns error because we cannot determine if bundle is enabled or disabled", func() {
fs.ReadAndFollowLinkError = errors.New("fake-read-link-error")
err := fileBundle.Disable()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-read-link-error"))
})
})
})
Describe("Uninstall", func() {
It("removes the files from disk", func() {
_, _, err := fileBundle.Install(sourcePath)
Expect(err).NotTo(HaveOccurred())
err = fileBundle.Uninstall()
Expect(err).NotTo(HaveOccurred())
示例2: describeUbuntuNetManager
//.........這裏部分代碼省略.........
resolvConfBase := fs.GetFileTestStat("/etc/resolvconf/resolv.conf.d/base")
Expect(resolvConfBase).ToNot(BeNil())
expectedResolvConfBase := `# Generated by bosh-agent
nameserver 8.8.8.8
nameserver 9.9.9.9
`
Expect(resolvConfBase.StringContents()).To(Equal(expectedResolvConfBase))
})
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.ReadAndFollowLinkError = 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"))