当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeFileSystem.RegisterReadFileError方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.RegisterReadFileError方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeFileSystem.RegisterReadFileError方法的具体用法?Golang FakeFileSystem.RegisterReadFileError怎么用?Golang FakeFileSystem.RegisterReadFileError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem的用法示例。


在下文中一共展示了FakeFileSystem.RegisterReadFileError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

				Expect(fakeBlobstore.GetError).ToNot(HaveOccurred())
				Expect(fakeBlobstore.GetFileName).ToNot(Equal(""))
			})

			It("reads the DNS records from the blobstore file", func() {
				response, err := syncDNS.Run("fake-blobstore-id", "fake-fingerprint")
				Expect(err).ToNot(HaveOccurred())
				Expect(response).To(Equal("synced"))

				Expect(fakeBlobstore.GetError).ToNot(HaveOccurred())
				Expect(fakeBlobstore.GetFileName).To(Equal("fake-blobstore-file-path"))
				Expect(fakeFileSystem.ReadFileError).ToNot(HaveOccurred())
			})

			It("fails reading the DNS records from the blobstore file", func() {
				fakeFileSystem.RegisterReadFileError("fake-blobstore-file-path", errors.New("fake-error"))

				response, err := syncDNS.Run("fake-blobstore-id", "fake-fingerprint")
				Expect(err).To(HaveOccurred())
				Expect(response).To(Equal(""))
				Expect(err.Error()).To(ContainSubstring("Reading fileName"))
			})

			It("deletes the file once read", func() {
				_, err := syncDNS.Run("fake-blobstore-id", "fake-fingerprint")
				Expect(err).ToNot(HaveOccurred())

				Expect(fakeFileSystem.FileExists("fake-blobstore-file-path")).To(BeFalse())
			})

			It("logs when the dns blob file can't be deleted", func() {
开发者ID:mattcui,项目名称:bosh-init,代码行数:31,代码来源:sync_dns_test.go

示例2:

		Context("When the path to the agent's state is ''", func() {
			It("returns an error and a state object with false properties", func() {
				s, err = platform.NewBootstrapState(fs, "")

				Expect(s.Linux.HostsConfigured).To(BeFalse())
			})
		})

		Context("When the agent cannot read the state file due to a failed disk", func() {
			It("returns an error and a state object with false properties", func() {
				fs.WriteFileString(path, `{
					"hosts_configured": true,
					"hostname_configured": true
				}`)

				fs.RegisterReadFileError(path, errors.New("ENXIO: disk failed"))

				_, readerr := platform.NewBootstrapState(fs, path)

				Expect(readerr.Error()).To(ContainSubstring("disk failed"))
			})
		})

		Context("When the agent cannot parse the state file due to malformed JSON", func() {
			It("returns an error and a state object with false properties", func() {
				fs.WriteFileString(path, "malformed-JSON")

				_, readerr := platform.NewBootstrapState(fs, path)

				Expect(readerr).To(HaveOccurred())
			})
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:31,代码来源:bootstrap_state_test.go

示例3:

					Expect(fakeBlobstore.GetError).ToNot(HaveOccurred())
					Expect(fakeBlobstore.GetFileName).ToNot(Equal(""))
				})

				It("reads the DNS records from the blobstore file", func() {
					response, err := action.Run("fake-blobstore-id", "fake-fingerprint", 2)
					Expect(err).ToNot(HaveOccurred())
					Expect(response).To(Equal("synced"))

					Expect(fakeBlobstore.GetError).ToNot(HaveOccurred())
					Expect(fakeBlobstore.GetFileName).To(Equal("fake-blobstore-file-path"))
					Expect(fakeFileSystem.ReadFileError).ToNot(HaveOccurred())
				})

				It("fails reading the DNS records from the blobstore file", func() {
					fakeFileSystem.RegisterReadFileError("fake-blobstore-file-path", errors.New("fake-error"))

					response, err := action.Run("fake-blobstore-id", "fake-fingerprint", 2)
					Expect(err).To(HaveOccurred())
					Expect(response).To(Equal(""))
					Expect(err.Error()).To(ContainSubstring("reading fake-blobstore-file-path from blobstore"))
					Expect(fakeFileSystem.FileExists("fake-blobstore-file-path")).To(BeFalse())
				})

				It("deletes the file once read", func() {
					_, err := action.Run("fake-blobstore-id", "fake-fingerprint", 2)
					Expect(err).ToNot(HaveOccurred())

					Expect(fakeFileSystem.FileExists("fake-blobstore-file-path")).To(BeFalse())
				})
开发者ID:mattcui,项目名称:bosh-agent,代码行数:30,代码来源:sync_dns_test.go


注:本文中的github.com/cloudfoundry/bosh-utils/system/fakes.FakeFileSystem.RegisterReadFileError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。