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


Golang Server.GetHandler方法代码示例

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


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

示例1:

				),
			)
		})

		AfterEach(func() {
			ccServer.Close()
		})

		It("tries to create the app", func() {
			repo.Create(appParams)
			Expect(ccServer.ReceivedRequests()).To(HaveLen(1))
		})

		Context("when the create succeeds", func() {
			BeforeEach(func() {
				h := ccServer.GetHandler(0)
				ccServer.SetHandler(0,
					ghttp.CombineHandlers(
						h,
						ghttp.RespondWith(http.StatusCreated, `{
							"metadata": {
									"guid": "my-cool-app-guid"
							},
							"entity": {
									"name": "my-cool-app"
							}
					}`),
					),
				)
			})
开发者ID:yingkitw,项目名称:cli,代码行数:30,代码来源:applications_test.go

示例2:

				It("Should create 'get' command with proper name", func() {
					Expect(getCommand.Name).To(Equal("tower show"))
				})

				It("Should get resource successfully", func() {
					result, err := getCommand.Action([]string{icyTowerID})
					Expect(err).ToNot(HaveOccurred())
					var resultJSON interface{}
					json.Unmarshal([]byte(result), &resultJSON)
					Expect(resultJSON).To(Equal(getIcyTower()))
				})

				It("Should get resource by name successfully", func() {
					server.SetHandler(1, ghttp.RespondWith(404, nil))
					handler := server.GetHandler(2)
					server.SetHandler(2, ghttp.RespondWithJSONEncoded(200, getIcyTowerListResponse()))
					server.AppendHandlers(handler)
					result, err := getCommand.Action([]string{icyTowerName})
					Expect(err).ToNot(HaveOccurred())
					var resultJSON interface{}
					json.Unmarshal([]byte(result), &resultJSON)
					Expect(resultJSON).To(Equal(getIcyTower()))
				})

				It("Should show error - wrong number of arguments", func() {
					result, err := getCommand.Action([]string{})
					Expect(result).To(Equal(""))
					Expect(err).To(MatchError("Wrong number of arguments"))
				})
开发者ID:cloudwan,项目名称:gohan,代码行数:29,代码来源:client_test.go


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