spaceQuotaRepo *spacequotasfakes.FakeSpaceQuotaRepository OriginalCommand commandregistry.Command deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo) deps.RepoLocator = deps.RepoLocator.SetSpaceQuotaRepository(spaceQuotaRepo) deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo) deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo) deps.RepoLocator = deps.RepoLocator.SetUserRepository(userRepo) deps.Config = configRepo //inject fake 'command dependency' into registry commandregistry.Register(spaceRoleSetter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("create-space").SetDependency(deps, pluginCall)) } runCommand := func(args ...string) bool { return testcmd.RunCLICommand("create-space", args, requirementsFactory, updateCommandDependency, false, ui) } BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() orgRepo = new(organizationsfakes.FakeOrganizationRepository) userRepo = new(apifakes.FakeUserRepository) spaceRoleSetter = commandregistry.Commands.FindCommand("set-space-role").(user.SpaceRoleSetter)
func init() { commandregistry.Register(&BindRouteService{}) }
func init() { commandregistry.Register(&CreateDomain{}) }
func init() { commandregistry.Register(&UnsharePrivateDomain{}) }
func init() { commandregistry.Register(&MarketplaceServices{}) }
func init() { commandregistry.Register(&UpdateService{}) }
func init() { commandregistry.Register(&PurgeServiceOffering{}) }
func init() { commandregistry.Register(&Version{}) }
appRestarter *applicationfakes.FakeRestarter OriginalCommand commandregistry.Command deps commandregistry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.RepoLocator = deps.RepoLocator.SetAuthenticationRepository(authRepo) deps.RepoLocator = deps.RepoLocator.SetApplicationRepository(appRepo) deps.RepoLocator = deps.RepoLocator.SetCopyApplicationSourceRepository(copyAppSourceRepo) deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo) deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo) deps.Config = config //inject fake 'command dependency' into registry commandregistry.Register(appRestarter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("copy-source").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} requirementsFactory = new(requirementsfakes.FakeFactory) authRepo = new(authenticationfakes.FakeRepository) appRepo = new(applicationsfakes.FakeRepository) copyAppSourceRepo = new(copyapplicationsourcefakes.FakeRepository) spaceRepo = new(spacesfakes.FakeSpaceRepository) orgRepo = new(organizationsfakes.FakeOrganizationRepository) config = testconfig.NewRepositoryWithDefaults() //save original command and restore later
func init() { commandregistry.Register(&DeleteSharedDomain{}) }
func init() { commandregistry.Register(&UpdateSecurityGroup{}) }
func init() { commandregistry.Register(&ShowFeatureFlag{}) }
func init() { commandregistry.Register(&DisallowSpaceSSH{}) }
func init() { commandregistry.Register(&Files{}) }
func init() { commandregistry.Register(&AddPluginRepo{}) }
//save original command and restore later originalSSHCodeGetter = commandregistry.Commands.FindCommand("ssh-code") sshCodeGetter = new(commandsfakes.FakeSSHCodeGetter) //setup fakes to correctly interact with commandregistry sshCodeGetter.SetDependencyStub = func(_ commandregistry.Dependency, _ bool) commandregistry.Command { return sshCodeGetter } sshCodeGetter.MetaDataReturns(commandregistry.CommandMetadata{Name: "ssh-code"}) }) AfterEach(func() { //restore original command commandregistry.Register(originalSSHCodeGetter) }) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.Config = configRepo //inject fake 'sshCodeGetter' into registry commandregistry.Register(sshCodeGetter) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("ssh").SetDependency(deps, pluginCall)) } runCommand := func(args ...string) bool { return testcmd.RunCLICommand("ssh", args, requirementsFactory, updateCommandDependency, false, ui) }
func init() { commandregistry.Register(&UnsetEnv{}) }
Context("i18n", func() { It("initialize i18n T() func", func() { Expect(T).ToNot(BeNil()) }) }) Describe("Register()", func() { AfterEach(func() { commandregistry.Commands.RemoveCommand("fake-command2") }) It("registers a command and its alias into the Command Registry map", func() { Expect(commandregistry.Commands.CommandExists("fake-command2")).To(BeFalse()) Expect(commandregistry.Commands.CommandExists("fc2")).To(BeFalse()) commandregistry.Register(FakeCommand2{}) Expect(commandregistry.Commands.CommandExists("fake-command2")).To(BeTrue()) Expect(commandregistry.Commands.CommandExists("fc2")).To(BeTrue()) }) }) Describe("CommandExists()", func() { Context("when the command has been registered", func() { BeforeEach(func() { commandregistry.Register(FakeCommand1{}) }) AfterEach(func() { commandregistry.Commands.RemoveCommand("fake-command") })
runCommand(test_with_help, "-f") Expect(ui.Outputs()).To(ContainSubstrings( []string{"Command `help` in the plugin being installed is a native CF command/alias. Rename the `help` command in the plugin being installed in order to enable its installation and use."}, []string{"FAILED"}, )) }) }) Context("when the plugin's command conflicts with a core command/alias", func() { var originalCommand commandregistry.Command BeforeEach(func() { originalCommand = commandregistry.Commands.FindCommand("org") commandregistry.Register(testOrgsCmd{}) }) AfterEach(func() { if originalCommand != nil { commandregistry.Register(originalCommand) } }) It("fails if is shares a command name", func() { runCommand(test_with_orgs, "-f") Expect(ui.Outputs()).To(ContainSubstrings( []string{"Command `orgs` in the plugin being installed is a native CF command/alias. Rename the `orgs` command in the plugin being installed in order to enable its installation and use."}, []string{"FAILED"}, ))
func init() { commandregistry.Register(&ListStacks{}) }
func init() { commandregistry.Register(&Target{}) }
func init() { commandregistry.Register(&ListQuotas{}) }
starter *applicationfakes.FakeStarter stopper *applicationfakes.FakeStopper config coreconfig.Repository app models.Application originalStop commandregistry.Command originalStart commandregistry.Command deps commandregistry.Dependency applicationReq *requirementsfakes.FakeApplicationRequirement ) updateCommandDependency := func(pluginCall bool) { deps.UI = ui deps.Config = config //inject fake 'stopper and starter' into registry commandregistry.Register(starter) commandregistry.Register(stopper) commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("restart").SetDependency(deps, pluginCall)) } runCommand := func(args ...string) bool { return testcmd.RunCLICommand("restart", args, requirementsFactory, updateCommandDependency, false, ui) } BeforeEach(func() { ui = &testterm.FakeUI{} deps = commandregistry.NewDependency(os.Stdout, new(tracefakes.FakePrinter), "") requirementsFactory = new(requirementsfakes.FakeFactory) starter = new(applicationfakes.FakeStarter) stopper = new(applicationfakes.FakeStopper)
func init() { commandregistry.Register(&showQuota{}) }
func init() { commandregistry.Register(&RemovePluginRepo{}) }
func init() { commandregistry.Register(&ServiceAccess{}) }
func init() { commandregistry.Register(&SpaceQuota{}) }
func init() { commandregistry.Register(&SSHEnabled{}) }
func init() { commandregistry.Register(&UnsetOrgRole{}) }
func init() { commandregistry.Register(&UnmapRoute{}) }