當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeV1Service.ResolveDynamicNetworksErr方法代碼示例

本文整理匯總了Golang中bosh/agent/applier/applyspec/fakes.FakeV1Service.ResolveDynamicNetworksErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeV1Service.ResolveDynamicNetworksErr方法的具體用法?Golang FakeV1Service.ResolveDynamicNetworksErr怎麽用?Golang FakeV1Service.ResolveDynamicNetworksErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bosh/agent/applier/applyspec/fakes.FakeV1Service的用法示例。


在下文中一共展示了FakeV1Service.ResolveDynamicNetworksErr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init

func init() {
	Describe("ApplyAction", func() {
		var (
			applier     *fakeappl.FakeApplier
			specService *fakeas.FakeV1Service
			action      ApplyAction
		)

		BeforeEach(func() {
			applier = fakeappl.NewFakeApplier()
			specService = fakeas.NewFakeV1Service()
			action = NewApply(applier, specService)
		})

		It("apply should be asynchronous", func() {
			Expect(action.IsAsynchronous()).To(BeTrue())
		})

		It("is not persistent", func() {
			Expect(action.IsPersistent()).To(BeFalse())
		})

		Describe("Run", func() {
			Context("when desired spec has configuration hash", func() {
				currentApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-current-config-hash"}
				desiredApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-desired-config-hash"}
				resolvedDesiredApplySpec := boshas.V1ApplySpec{
					ConfigurationHash: "fake-resolved-desired-config-hash",
				}

				Context("when current spec can be retrieved", func() {
					BeforeEach(func() {
						specService.Spec = currentApplySpec
					})

					It("resolves dynamic networks in desired spec", func() {
						_, err := action.Run(desiredApplySpec)
						Expect(err).ToNot(HaveOccurred())
						Expect(specService.ResolveDynamicNetworksSpec).To(Equal(desiredApplySpec))
					})

					Context("when resolving dynamic networks succeeds", func() {
						BeforeEach(func() {
							specService.ResolveDynamicNetworksResultSpec = resolvedDesiredApplySpec
						})

						It("runs applier with resolved desired spec", func() {
							_, err := action.Run(desiredApplySpec)
							Expect(err).ToNot(HaveOccurred())
							Expect(applier.Applied).To(BeTrue())
							Expect(applier.ApplyCurrentApplySpec).To(Equal(currentApplySpec))
							Expect(applier.ApplyDesiredApplySpec).To(Equal(resolvedDesiredApplySpec))
						})

						Context("when applier succeeds applying desired spec", func() {
							Context("when saving desires spec as current spec succeeds", func() {
								It("returns 'applied' after setting resolved desired spec as current spec", func() {
									value, err := action.Run(desiredApplySpec)
									Expect(err).ToNot(HaveOccurred())
									Expect(value).To(Equal("applied"))

									Expect(specService.Spec).To(Equal(resolvedDesiredApplySpec))
								})
							})

							Context("when saving resolved desires spec as current spec fails", func() {
								It("returns error because agent was not able to remember that is converged to desired spec", func() {
									specService.SetErr = errors.New("fake-set-error")

									_, err := action.Run(desiredApplySpec)
									Expect(err).To(HaveOccurred())
									Expect(err.Error()).To(ContainSubstring("fake-set-error"))
								})
							})
						})

						Context("when applier fails applying desired spec", func() {
							BeforeEach(func() {
								applier.ApplyError = errors.New("fake-apply-error")
							})

							It("returns error", func() {
								_, err := action.Run(desiredApplySpec)
								Expect(err).To(HaveOccurred())
								Expect(err.Error()).To(ContainSubstring("fake-apply-error"))
							})

							It("does not save desired spec as current spec", func() {
								_, err := action.Run(desiredApplySpec)
								Expect(err).To(HaveOccurred())
								Expect(specService.Spec).To(Equal(currentApplySpec))
							})
						})
					})

					Context("when resolving dynamic networks fails", func() {
						BeforeEach(func() {
							specService.ResolveDynamicNetworksErr = errors.New("fake-resolve-dynamic-networks-err")
						})

//.........這裏部分代碼省略.........
開發者ID:Jane4PKU,項目名稱:bosh,代碼行數:101,代碼來源:apply_test.go


注:本文中的bosh/agent/applier/applyspec/fakes.FakeV1Service.ResolveDynamicNetworksErr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。