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


Golang FakeServiceBrokerRepository.FindByNameReturns方法代码示例

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


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

示例1:

				ServiceOfferingFields: models.ServiceOfferingFields{
					Label:      "my-other-public-service",
					GUID:       "my-other-public-service-guid",
					BrokerGUID: "my-other-service-broker-guid",
				},
				Plans: []models.ServicePlanFields{
					publicServicePlan,
					privateServicePlan,
				},
			}
			services = append(services, service3)
		})

		It("attaches a single broker to only services that match", func() {
			serviceBroker1.Services = models.ServiceOfferings{}
			brokerRepo.FindByNameReturns(serviceBroker1, nil)
			broker, err := brokerBuilder.AttachSpecificBrokerToServices("my-service-broker", services)

			Expect(err).NotTo(HaveOccurred())
			Expect(broker.Name).To(Equal("my-service-broker"))
			Expect(broker.Services[0].Label).To(Equal("my-public-service"))
			Expect(len(broker.Services[0].Plans)).To(Equal(2))
			Expect(broker.Services[1].Label).To(Equal("my-other-public-service"))
			Expect(len(broker.Services[0].Plans)).To(Equal(2))
			Expect(len(broker.Services)).To(Equal(2))
		})
	})

	Describe(".GetAllServiceBrokers", func() {
		It("returns an error if we cannot list all brokers", func() {
			brokerRepo.ListServiceBrokersReturns(errors.New("Error finding service brokers"))
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:broker_builder_test.go

示例2:

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Incorrect Usage", "Requires an argument"},
			))
		})

		It("fails requirements when not logged in", func() {
			requirementsFactory.LoginSuccess = false

			Expect(runCommand("-f", "my-broker")).To(BeFalse())
		})
	})

	Context("when the service broker exists", func() {
		BeforeEach(func() {
			brokerRepo.FindByNameReturns(models.ServiceBroker{
				Name: "service-broker-to-delete",
				GUID: "service-broker-to-delete-guid",
			}, nil)
		})

		It("deletes the service broker with the given name", func() {
			runCommand("service-broker-to-delete")
			Expect(brokerRepo.FindByNameCallCount()).To(Equal(1))
			Expect(brokerRepo.FindByNameArgsForCall(0)).To(Equal("service-broker-to-delete"))
			Expect(brokerRepo.DeleteCallCount()).To(Equal(1))
			Expect(brokerRepo.DeleteArgsForCall(0)).To(Equal("service-broker-to-delete-guid"))
			Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the service-broker service-broker-to-delete"}))

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Deleting service broker", "service-broker-to-delete", "my-user"},
				[]string{"OK"},
			))
开发者ID:yingkitw,项目名称:cli,代码行数:32,代码来源:delete_service_broker_test.go

示例3:

				[]string{"Incorrect Usage", "Requires", "arguments"},
			))
		})

		It("fails when not logged in", func() {
			Expect(runCommand("okay", "DO---IIIIT")).To(BeFalse())
		})
	})

	Context("when logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			broker := models.ServiceBroker{}
			broker.Name = "my-found-broker"
			broker.GUID = "my-found-broker-guid"
			serviceBrokerRepo.FindByNameReturns(broker, nil)
		})

		It("renames the given service broker", func() {
			runCommand("my-broker", "my-new-broker")
			Expect(serviceBrokerRepo.FindByNameCallCount()).To(Equal(1))
			Expect(serviceBrokerRepo.FindByNameArgsForCall(0)).To(Equal("my-broker"))

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Renaming service broker", "my-found-broker", "my-new-broker", "my-user"},
				[]string{"OK"},
			))

			Expect(serviceBrokerRepo.RenameCallCount()).To(Equal(1))
			guid, name := serviceBrokerRepo.RenameArgsForCall(0)
			Expect(guid).To(Equal("my-found-broker-guid"))
开发者ID:yingkitw,项目名称:cli,代码行数:31,代码来源:rename_service_broker_test.go


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