var _ = Describe("app Command", func() { var ( ui *testterm.FakeUI configRepo core_config.Repository appSummaryRepo *testapi.FakeAppSummaryRepo appInstancesRepo *testAppInstanaces.FakeAppInstancesRepository appLogsNoaaRepo *testapi.FakeLogsNoaaRepository requirementsFactory *testreq.FakeReqFactory app models.Application deps command_registry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.Ui = ui deps.RepoLocator = deps.RepoLocator.SetLogsNoaaRepository(appLogsNoaaRepo) deps.Config = configRepo deps.RepoLocator = deps.RepoLocator.SetAppSummaryRepository(appSummaryRepo) deps.RepoLocator = deps.RepoLocator.SetAppInstancesRepository(appInstancesRepo) command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("app").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} appSummaryRepo = &testapi.FakeAppSummaryRepo{} appLogsNoaaRepo = &testapi.FakeLogsNoaaRepository{} appInstancesRepo = &testAppInstanaces.FakeAppInstancesRepository{} configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{ LoginSuccess: true, TargetedSpaceSuccess: true, }
var ( Flags []string Config core_config.Repository ui *testterm.FakeUI authRepo *testapi.FakeAuthenticationRepository endpointRepo *testapi.FakeEndpointRepo orgRepo *fake_organizations.FakeOrganizationRepository spaceRepo *testapi.FakeSpaceRepository org models.Organization deps command_registry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.Ui = ui deps.Config = Config deps.RepoLocator = deps.RepoLocator.SetEndpointRepository(endpointRepo) deps.RepoLocator = deps.RepoLocator.SetAuthenticationRepository(authRepo) deps.RepoLocator = deps.RepoLocator.SetOrganizationRepository(orgRepo) deps.RepoLocator = deps.RepoLocator.SetSpaceRepository(spaceRepo) command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("login").SetDependency(deps, pluginCall)) } listSpacesStub := func(spaces []models.Space) func(func(models.Space) bool) error { return func(cb func(models.Space) bool) error { var keepGoing bool for _, s := range spaces { keepGoing = cb(s) if !keepGoing { return nil }
"github.com/cloudfoundry/cli/cf/configuration/core_config" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("stack command", func() { var ( ui *testterm.FakeUI config core_config.Repository repo *testapi.FakeStackRepository requirementsFactory *testreq.FakeReqFactory deps command_registry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.Ui = ui deps.Config = config deps.RepoLocator = deps.RepoLocator.SetStackRepository(repo) command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("stack").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} config = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true} repo = &testapi.FakeStackRepository{} }) Describe("login requirements", func() { It("fails if the user is not logged in", func() { requirementsFactory.LoginSuccess = false
. "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/cloudfoundry/cli/testhelpers/matchers" ) var _ = Describe("password command", func() { var ( pwDeps passwordDeps ui *testterm.FakeUI deps command_registry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.Ui = ui deps.Config = pwDeps.Config deps.RepoLocator = deps.RepoLocator.SetPasswordRepository(pwDeps.PwdRepo) command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("passwd").SetDependency(deps, pluginCall)) } callPassword := func(inputs []string, pwDeps passwordDeps) (*testterm.FakeUI, bool) { ui = &testterm.FakeUI{Inputs: inputs} passed := testcmd.RunCliCommand("passwd", []string{}, pwDeps.ReqFactory, updateCommandDependency, false) return ui, passed } BeforeEach(func() { pwDeps = getPasswordDeps() }) It("does not pass requirements if you are not logged in", func() {