本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeServiceInstanceRequirement类的典型用法代码示例。如果您正苦于以下问题:Golang FakeServiceInstanceRequirement类的具体用法?Golang FakeServiceInstanceRequirement怎么用?Golang FakeServiceInstanceRequirement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeServiceInstanceRequirement类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
"fmt"
"github.com/cloudfoundry/cli/cf/api/applications/applicationsfakes"
"github.com/cloudfoundry/cli/plugin/models"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("service command", func() {
var (
ui *testterm.FakeUI
deps commandregistry.Dependency
flagContext flags.FlagContext
reqFactory *requirementsfakes.FakeFactory
loginRequirement requirements.Requirement
targetedSpaceRequirement requirements.Requirement
serviceInstanceRequirement *requirementsfakes.FakeServiceInstanceRequirement
pluginCall bool
cmd *service.ShowService
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
pluginCall = false
appRepo := new(applicationsfakes.FakeRepository)
appRepo.GetAppStub = func(appGUID string) (models.Application, error) {
if appGUID == "app1-guid" {
return models.Application{
ApplicationFields: models.ApplicationFields{
开发者ID:Reejoshi,项目名称:cli,代码行数:32,代码来源:service_test.go
示例2:
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("UpdateUserProvidedService", func() {
var (
ui *testterm.FakeUI
configRepo coreconfig.Repository
serviceInstanceRepo *apifakes.FakeUserProvidedServiceInstanceRepository
cmd commandregistry.Command
deps commandregistry.Dependency
factory *requirementsfakes.FakeFactory
flagContext flags.FlagContext
loginRequirement requirements.Requirement
minAPIVersionRequirement requirements.Requirement
serviceInstanceRequirement *requirementsfakes.FakeServiceInstanceRequirement
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
serviceInstanceRepo = new(apifakes.FakeUserProvidedServiceInstanceRepository)
repoLocator := deps.RepoLocator.SetUserProvidedServiceInstanceRepository(serviceInstanceRepo)
deps = commandregistry.Dependency{
UI: ui,
开发者ID:yingkitw,项目名称:cli,代码行数:32,代码来源:update_user_provided_service_test.go
示例3:
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-service-key").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
serviceRepo = &apifakes.FakeServiceRepository{}
serviceInstance := models.ServiceInstance{}
serviceInstance.GUID = "fake-instance-guid"
serviceInstance.Name = "fake-service-instance"
serviceRepo.FindInstanceByNameReturns(serviceInstance, nil)
serviceKeyRepo = apifakes.NewFakeServiceKeyRepo()
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
serviceInstanceReq := new(requirementsfakes.FakeServiceInstanceRequirement)
requirementsFactory.NewServiceInstanceRequirementReturns(serviceInstanceReq)
serviceInstanceReq.GetServiceInstanceReturns(serviceInstance)
})
var callCreateService = func(args []string) bool {
return testcmd.RunCLICommand("create-service-key", args, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements", func() {
It("fails when not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(callCreateService([]string{"fake-service-instance", "fake-service-key"})).To(BeFalse())
})
It("requires two arguments to run", func() {
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:create_service_key_test.go
示例4:
ApplicationFields: models.ApplicationFields{
Name: "my-app",
GUID: "my-app-guid",
},
}
serviceInstance = models.ServiceInstance{
ServiceInstanceFields: models.ServiceInstanceFields{
Name: "my-service",
GUID: "my-service-guid",
},
}
applicationReq := new(requirementsfakes.FakeApplicationRequirement)
applicationReq.GetApplicationReturns(app)
requirementsFactory.NewApplicationRequirementReturns(applicationReq)
serviceInstanceReq := new(requirementsfakes.FakeServiceInstanceRequirement)
serviceInstanceReq.GetServiceInstanceReturns(serviceInstance)
requirementsFactory.NewServiceInstanceRequirementReturns(serviceInstanceReq)
})
It("binds a service instance to an app", func() {
callBindService([]string{"my-app", "my-service"})
Expect(ui.Outputs()).To(ContainSubstrings(
[]string{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"},
[]string{"OK"},
[]string{"TIP", "my-app"},
))
Expect(serviceBindingRepo.CreateCallCount()).To(Equal(1))
serviceInstanceGUID, applicationGUID, _ := serviceBindingRepo.CreateArgsForCall(0)
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:bind_service_test.go
注:本文中的github.com/cloudfoundry/cli/cf/requirements/requirementsfakes.FakeServiceInstanceRequirement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论