Expect(Config.APIEndpoint()).To(Equal("api.example.com")) Expect(Config.APIVersion()).To(Equal("some-version")) Expect(Config.AuthenticationEndpoint()).To(Equal("auth/endpoint")) Expect(Config.SSHOAuthClient()).To(Equal("some-client")) Expect(Config.MinCLIVersion()).To(Equal("1.0.0")) Expect(Config.MinRecommendedCLIVersion()).To(Equal("1.0.0")) Expect(Config.LoggregatorEndpoint()).To(Equal("loggregator/endpoint")) Expect(Config.DopplerEndpoint()).To(Equal("doppler/endpoint")) Expect(Config.RoutingAPIEndpoint()).To(Equal("routing/endpoint")) Expect(endpointRepo.GetCCInfoCallCount()).To(Equal(1)) Expect(endpointRepo.GetCCInfoArgsForCall(0)).To(Equal("api.example.com")) Expect(orgRepo.FindByNameArgsForCall(0)).To(Equal("my-new-org")) Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("my-space")) Expect(ui.ShowConfigurationCalled).To(BeTrue()) }) It("lets the user select an org and space by name", func() { ui.Inputs = []string{"api.example.com", "*****@*****.**", "password", "my-new-org", "my-space"} orgRepo.FindByNameReturns(org2, nil) 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"},
spaceRepo = new(apifakes.FakeSpaceRepository) }) Context("when a space with the given name exists", func() { It("succeeds", func() { space := models.Space{} space.Name = "awesome-sauce-space" space.GUID = "my-space-guid" spaceRepo.FindByNameReturns(space, nil) spaceReq := NewSpaceRequirement("awesome-sauce-space", spaceRepo) err := spaceReq.Execute() Expect(err).NotTo(HaveOccurred()) Expect(spaceReq.GetSpace()).To(Equal(space)) Expect(spaceRepo.FindByNameArgsForCall(0)).To(Equal("awesome-sauce-space")) }) }) Context("when a space with the given name does not exist", func() { It("errors", func() { spaceError := errors.New("space-repo-err") spaceRepo.FindByNameReturns(models.Space{}, spaceError) err := NewSpaceRequirement("foo", spaceRepo).Execute() Expect(err).To(HaveOccurred()) Expect(err).To(Equal(spaceError)) }) }) })