本文整理汇总了Golang中github.com/cloudfoundry/cli/testhelpers/commands.RunCliCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang RunCliCommand函数的具体用法?Golang RunCliCommand怎么用?Golang RunCliCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunCliCommand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: callApi
func callApi(args []string, config core_config.Repository, endpointRepo *testapi.FakeEndpointRepo) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
// cmd := NewApi(ui, config, endpointRepo)
var cmd command_registry.Command
cmd = Api{}
repoLocator := api.RepositoryLocator{}
repoLocator = repoLocator.SetEndpointRepository(endpointRepo)
deps := command_registry.Dependency{
Ui: ui,
Config: config,
RepoLocator: repoLocator,
}
cmd = cmd.SetDependency(deps, false)
requirementsFactory := &testreq.FakeReqFactory{}
testcmd.RunCliCommand(cmd, args, requirementsFactory)
return
}
示例2:
requirementsFactory = &testreq.FakeReqFactory{
LoginSuccess: true,
TargetedSpaceSuccess: true,
Application: application,
}
})
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = config
deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("restart-app-instance").SetDependency(deps, pluginCall))
}
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("restart-app-instance", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails if not logged in", func() {
requirementsFactory.LoginSuccess = false
Expect(runCommand("my-app", "0")).To(BeFalse())
})
It("fails if a space is not targeted", func() {
requirementsFactory.TargetedSpaceSuccess = false
Expect(runCommand("my-app", "0")).To(BeFalse())
})
It("fails when there is not exactly two arguments", func() {
Expect(runCommand("my-app")).To(BeFalse())
示例3:
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("org-users").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
userRepo = &testapi.FakeUserRepository{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
deps = command_registry.NewDependency()
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("org-users", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails with usage when invoked without an org name", func() {
requirementsFactory.LoginSuccess = true
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
It("fails when not logged in", func() {
Expect(runCommand("say-hello-to-my-little-org")).To(BeFalse())
})
})
示例4:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetUserProvidedServiceInstanceRepository(serviceRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("update-user-provided-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
serviceRepo = &testapi.FakeUserProvidedServiceInstanceRepository{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("update-user-provided-service", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails with usage when not provided the name of the service to update", func() {
requirementsFactory.LoginSuccess = true
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "argument"},
))
})
It("fails when not logged in", func() {
Expect(runCommand("whoops")).To(BeFalse())
})
})
示例5:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetLogsRepository(logsRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("logs").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
logsRepo = &testapi.FakeLogsRepository{}
requirementsFactory = &testreq.FakeReqFactory{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("logs", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails with usage when called without one argument", func() {
requirementsFactory.LoginSuccess = true
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
It("fails requirements when not logged in", func() {
Expect(runCommand("my-app")).To(BeFalse())
})
示例6:
configRepo core_config.Repository
reqFactory *testreq.FakeReqFactory
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetRouteRepository(routeRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("delete-orphaned-routes").SetDependency(deps, pluginCall))
}
callDeleteOrphanedRoutes := func(confirmation string, args []string, reqFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (*testterm.FakeUI, bool) {
ui = &testterm.FakeUI{Inputs: []string{confirmation}}
configRepo = testconfig.NewRepositoryWithDefaults()
passed := testcmd.RunCliCommand("delete-orphaned-routes", args, reqFactory, updateCommandDependency, false)
return ui, passed
}
BeforeEach(func() {
routeRepo = &testapi.FakeRouteRepository{}
reqFactory = &testreq.FakeReqFactory{}
})
It("fails requirements when not logged in", func() {
_, passed := callDeleteOrphanedRoutes("y", []string{}, reqFactory, routeRepo)
Expect(passed).To(BeFalse())
})
It("should fail with usage when provided any arguments", func() {
reqFactory.LoginSuccess = true
示例7:
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("unbind-security-group").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
requirementsFactory = &testreq.FakeReqFactory{}
securityGroupRepo = &fakeSecurityGroup.FakeSecurityGroupRepo{}
orgRepo = &fake_org.FakeOrganizationRepository{}
spaceRepo = &fakes.FakeSpaceRepository{}
secBinder = &fakeBinder.FakeSecurityGroupSpaceBinder{}
configRepo = testconfig.NewRepositoryWithDefaults()
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("unbind-security-group", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("should fail if not logged in", func() {
Expect(runCommand("my-group")).To(BeFalse())
})
It("should fail with usage when not provided with any arguments", func() {
requirementsFactory.LoginSuccess = true
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "arguments"},
))
})
示例8:
spaceRepo *testapi.FakeSpaceRepository
deps command_registry.Dependency
)
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.Config = configRepo
deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo)
deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo)
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("unset-space-role").SetDependency(deps, pluginCall))
}
callUnsetSpaceRole := func(args []string, spaceRepo *testapi.FakeSpaceRepository, userRepo *testapi.FakeUserRepository, requirementsFactory *testreq.FakeReqFactory) (*testterm.FakeUI, bool) {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
passed := testcmd.RunCliCommand("unset-space-role", args, requirementsFactory, updateCommandDependency, false)
return ui, passed
}
It("fails with usage when not called with exactly four args", func() {
requirementsFactory, spaceRepo, userRepo = getUnsetSpaceRoleDeps()
ui, _ := callUnsetSpaceRole([]string{"username", "org", "space"}, spaceRepo, userRepo, requirementsFactory)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "arguments"},
))
})
It("fails requirements when not logged in", func() {
requirementsFactory, spaceRepo, userRepo = getUnsetSpaceRoleDeps()
args := []string{"username", "org", "space", "role"}
示例9:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("disable-feature-flag").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
flagRepo = &fakeflag.FakeFeatureFlagRepository{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("disable-feature-flag", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("requires the user to be logged in", func() {
requirementsFactory.LoginSuccess = false
Expect(runCommand()).ToNot(HavePassedRequirements())
})
It("fails with usage if a single feature is not specified", func() {
runCommand()
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires an argument"},
))
})
})
示例10:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.Config = config
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("rename-service").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
serviceRepo = &testapi.FakeServiceRepository{}
requirementsFactory = &testreq.FakeReqFactory{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("rename-service", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("Fails with usage when exactly two parameters not passed", func() {
runCommand("whatever")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "arguments"},
))
})
It("fails when not logged in", func() {
requirementsFactory.TargetedSpaceSuccess = true
Expect(runCommand("banana", "fppants")).To(BeFalse())
})
示例11:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetDomainRepository(domainRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("delete-shared-domain").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
domainRepo = &testapi.FakeDomainRepository{}
requirementsFactory = &testreq.FakeReqFactory{}
configRepo = testconfig.NewRepositoryWithDefaults()
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("delete-shared-domain", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails if you are not logged in", func() {
requirementsFactory.TargetedOrgSuccess = true
Expect(runCommand("foo.com")).To(BeFalse())
})
It("fails if an organiztion is not targeted", func() {
requirementsFactory.LoginSuccess = true
Expect(runCommand("foo.com")).To(BeFalse())
})
})
示例12:
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetServiceBrokerRepository(serviceBrokerRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("create-service-broker").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
ui = &testterm.FakeUI{}
requirementsFactory = &testreq.FakeReqFactory{}
serviceBrokerRepo = &testapi.FakeServiceBrokerRepo{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("create-service-broker", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("fails with usage when called without exactly four args", func() {
requirementsFactory.LoginSuccess = true
runCommand("whoops", "not-enough", "args")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "Requires", "arguments"},
))
})
It("fails when not logged in", func() {
Expect(runCommand("Just", "Enough", "Args", "Provided")).To(BeFalse())
})
})
示例13:
spaceRepo.ListSpacesStub = listSpacesStub([]models.Space{space1, space2})
spaceRepo.FindByNameStub = func(name string) (models.Space, error) {
m := map[string]models.Space{
space1.Name: space1,
space2.Name: space2,
}
return m[name], nil
}
})
It("lets the user select an org and space by number", func() {
orgRepo.FindByNameReturns(org2, nil)
OUT_OF_RANGE_CHOICE := "3"
ui.Inputs = []string{"api.example.com", "[email protected]", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"}
testcmd.RunCliCommand("login", Flags, nil, updateCommandDependency, false)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Select an org"},
[]string{"1. some-org"},
[]string{"2. my-new-org"},
[]string{"Select a space"},
[]string{"1. my-space"},
[]string{"2. some-space"},
))
Expect(Config.OrganizationFields().Guid).To(Equal("my-new-org-guid"))
Expect(Config.SpaceFields().Guid).To(Equal("my-space-guid"))
Expect(Config.AccessToken()).To(Equal("my_access_token"))
Expect(Config.RefreshToken()).To(Equal("my_refresh_token"))
示例14:
updateCommandDependency := func(pluginCall bool) {
deps.Ui = ui
deps.RepoLocator = deps.RepoLocator.SetEnvironmentVariableGroupsRepository(environmentVariableGroupRepo)
deps.Config = configRepo
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("running-environment-variable-group").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true}
environmentVariableGroupRepo = &test_environmentVariableGroups.FakeEnvironmentVariableGroupsRepository{}
})
runCommand := func(args ...string) bool {
return testcmd.RunCliCommand("running-environment-variable-group", args, requirementsFactory, updateCommandDependency, false)
}
Describe("requirements", func() {
It("requires the user to be logged in", func() {
requirementsFactory.LoginSuccess = false
Expect(runCommand()).ToNot(HavePassedRequirements())
})
It("should fail with usage when provided any arguments", func() {
requirementsFactory.LoginSuccess = true
Expect(runCommand("blahblah")).To(BeFalse())
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Incorrect Usage", "No argument"},
))
})
})
示例15:
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.Config = config
command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("migrate-service-instances").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepository()
serviceRepo = &testapi.FakeServiceRepository{}
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: false}
args = []string{}
})
Describe("requirements", func() {
It("requires you to be logged in", func() {
Expect(testcmd.RunCliCommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false)).To(BeFalse())
})
It("requires five arguments to run", func() {
args = []string{"one", "two", "three"}
Expect(testcmd.RunCliCommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false)).To(BeFalse())
})
It("requires CC API version 2.47 or greater", func() {
requirementsFactory.MaxAPIVersionSuccess = false
requirementsFactory.LoginSuccess = true
args = []string{"one", "two", "three", "four", "five"}
ui.Inputs = append(ui.Inputs, "no")
Expect(testcmd.RunCliCommand("migrate-service-instances", args, requirementsFactory, updateCommandDependency, false)).To(BeFalse())