本文整理汇总了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"))
示例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"},
))
示例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"))