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


Golang FakeClient.DesiredLRPsReturns方法代码示例

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


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

示例1:

			fakeReceptorClientCreator.CreateReceptorClientReturns(fakeReceptorClient)
			targetVerifier = target_verifier.New(fakeReceptorClientCreator)
		})

		It("returns up=true, auth=true if the receptor does not return an error", func() {
			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
			Expect(err).NotTo(HaveOccurred())
			Expect(up).To(BeTrue())
			Expect(auth).To(BeTrue())
			Expect(fakeReceptorClientCreator.CreateReceptorClientCallCount()).To(Equal(1))
			Expect(fakeReceptorClientCreator.CreateReceptorClientArgsForCall(0)).To(Equal("http://receptor.mylattice.com"))
		})

		It("returns up=true, auth=false if the receptor returns an authorization error", func() {
			fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{
				Type:    receptor.Unauthorized,
				Message: "Go home. You're not welcome here.",
			})

			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
			Expect(err).NotTo(HaveOccurred())
			Expect(up).To(BeTrue())
			Expect(auth).To(BeFalse())
		})

		It("returns up=true, auth=false, err=(the bubbled up error) if there is a receptor error other than unauthorized", func() {
			fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{
				Type:    receptor.UnknownError,
				Message: "It all happened so fast... I just dunno what went wrong.",
			})

			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
开发者ID:davidwadden,项目名称:lattice-release,代码行数:32,代码来源:target_verifier_test.go

示例2:

							Port:   uint16(4444),
						},
					},
				}

				err := appRunner.CreateApp(createAppParams)
				Expect(err).NotTo(HaveOccurred())

				Expect(fakeReceptorClient.CreateDesiredLRPCallCount()).To(Equal(1))
				Expect(fakeReceptorClient.CreateDesiredLRPArgsForCall(0).Monitor).To(BeNil())
			})
		})

		Context("when monitoring a port", func() {
			It("sets the timeout for the monitor", func() {
				fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, nil)
				createAppParams = app_runner.CreateAppParams{
					AppEnvironmentParams: app_runner.AppEnvironmentParams{
						User: "monitor-runner",
						Monitor: app_runner.MonitorConfig{
							Method:  app_runner.PortMonitor,
							Port:    2345,
							Timeout: 15 * time.Second,
						},
						ExposedPorts: []uint16{2345},
					},
				}

				err := appRunner.CreateApp(createAppParams)
				Expect(err).NotTo(HaveOccurred())
开发者ID:davidwadden,项目名称:ltc,代码行数:30,代码来源:app_runner_test.go

示例3:

						DiskMB:      256,
						MemoryMB:    100,
						Routes: route_helpers.Routes{
							AppRoutes: route_helpers.AppRoutes{
								{Hostnames: []string{"happy", "joy"}},
							}}.RoutingInfo(),
						EnvironmentVariables: []receptor.EnvironmentVariable{},
						StartTimeout:         30,
						CPUWeight:            94,
						Ports:                []uint16{2378, 67},
						LogGuid:              "asdf-ojf93-9sdcsdk",
						LogSource:            "proc1-log",
						Annotation:           "Best process this side o' the Mississippi.",
					},
				}
				fakeReceptorClient.DesiredLRPsReturns(desiredLrps, nil)

				actualLrps := []receptor.ActualLRPResponse{
					{ProcessGuid: "process3-stopping", InstanceGuid: "guid4", Index: 1, State: receptor.ActualLRPStateRunning},
					{ProcessGuid: "process1-scalingUp", InstanceGuid: "guid1", Index: 1, State: receptor.ActualLRPStateRunning},
					{ProcessGuid: "process1-scalingUp", InstanceGuid: "guid2", Index: 2, State: receptor.ActualLRPStateClaimed},
					{ProcessGuid: "process2-scalingDown", InstanceGuid: "guid3", Index: 1, State: receptor.ActualLRPStateRunning},
				}
				fakeReceptorClient.ActualLRPsReturns(actualLrps, nil)
			})

			It("returns a list of alphabetically sorted examined apps", func() {
				appList, err := appExaminer.ListApps()

				Expect(err).NotTo(HaveOccurred())
				Expect(appList).To(HaveLen(3))
开发者ID:SrinivasChilveri,项目名称:ltc,代码行数:31,代码来源:app_examiner_test.go


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