func callShareDomain(args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) { fakeUI = new(testterm.FakeUI) ctxt := testcmd.NewContext("create-shared-domain", args) configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"}) cmd := NewCreateSharedDomain(fakeUI, configRepo, domainRepo) testcmd.RunCommand(cmd, ctxt, reqFactory) return }
func callListDomains(args []string, reqFactory *testreq.FakeReqFactory, domainRepo *testapi.FakeDomainRepository) (fakeUI *testterm.FakeUI) { fakeUI = new(testterm.FakeUI) ctxt := testcmd.NewContext("domains", args) configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"}) spaceFields := models.SpaceFields{} spaceFields.Name = "my-space" orgFields := models.OrganizationFields{} orgFields.Name = "my-org" configRepo.SetSpaceFields(spaceFields) configRepo.SetOrganizationFields(orgFields) cmd := domain.NewListDomains(fakeUI, configRepo, domainRepo) testcmd.RunCommand(cmd, ctxt, reqFactory) return }
func callCreateRoute(args []string, requirementsFactory *testreq.FakeReqFactory, routeRepo *testapi.FakeRouteRepository) (fakeUI *testterm.FakeUI) { fakeUI = new(testterm.FakeUI) ctxt := testcmd.NewContext("create-route", args) configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"}) spaceFields := models.SpaceFields{} spaceFields.Name = "my-space" orgFields := models.OrganizationFields{} orgFields.Name = "my-org" configRepo.SetSpaceFields(spaceFields) configRepo.SetOrganizationFields(orgFields) cmd := NewCreateRoute(fakeUI, configRepo, routeRepo) testcmd.RunCommand(cmd, ctxt, requirementsFactory) return }
func callListQuotas(reqFactory *testreq.FakeReqFactory, quotaRepo *testapi.FakeQuotaRepository) (fakeUI *testterm.FakeUI) { fakeUI = &testterm.FakeUI{} ctxt := testcmd.NewContext("quotas", []string{}) spaceFields := models.SpaceFields{} spaceFields.Name = "my-space" orgFields := models.OrganizationFields{} orgFields.Name = "my-org" token := configuration.TokenInfo{Username: "******"} config := testconfig.NewRepositoryWithAccessToken(token) config.SetSpaceFields(spaceFields) config.SetOrganizationFields(orgFields) cmd := organization.NewListQuotas(fakeUI, config, quotaRepo) testcmd.RunCommand(cmd, ctxt, reqFactory) return }
func callShowOrg(args []string, reqFactory *testreq.FakeReqFactory) (ui *testterm.FakeUI) { ui = new(testterm.FakeUI) ctxt := testcmd.NewContext("org", args) token := configuration.TokenInfo{Username: "******"} spaceFields := models.SpaceFields{} spaceFields.Name = "my-space" orgFields := models.OrganizationFields{} orgFields.Name = "my-org" configRepo := testconfig.NewRepositoryWithAccessToken(token) configRepo.SetSpaceFields(spaceFields) configRepo.SetOrganizationFields(orgFields) cmd := NewShowOrg(ui, configRepo) testcmd.RunCommand(cmd, ctxt, reqFactory) return }
func callDeleteSharedDomain(args []string, inputs []string, deps deleteSharedDomainDependencies) (ui *testterm.FakeUI) { ctxt := testcmd.NewContext("delete-domain", args) ui = &testterm.FakeUI{ Inputs: inputs, } configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"}) spaceFields := models.SpaceFields{} spaceFields.Name = "my-space" orgFields := models.OrganizationFields{} orgFields.Name = "my-org" configRepo.SetSpaceFields(spaceFields) configRepo.SetOrganizationFields(orgFields) cmd := domain.NewDeleteSharedDomain(ui, configRepo, deps.domainRepo) testcmd.RunCommand(cmd, ctxt, deps.requirementsFactory) return }
func callCreateOrg(args []string, requirementsFactory *testreq.FakeReqFactory, orgRepo *testapi.FakeOrgRepository) (fakeUI *testterm.FakeUI) { fakeUI = new(testterm.FakeUI) ctxt := testcmd.NewContext("create-org", args) space := models.SpaceFields{} space.Name = "my-space" organization := models.OrganizationFields{} organization.Name = "my-org" token := configuration.TokenInfo{Username: "******"} config := testconfig.NewRepositoryWithAccessToken(token) config.SetSpaceFields(space) config.SetOrganizationFields(organization) cmd := NewCreateOrg(fakeUI, config, orgRepo) testcmd.RunCommand(cmd, ctxt, requirementsFactory) return }
{"Not logged in", "Use", "log in"}, }) }) }) Context("when an api endpoint is set and the user logged in", func() { var config configuration.ReadWriter BeforeEach(func() { accessToken := configuration.TokenInfo{ UserGuid: "my-user-guid", Username: "******", Email: "my-user-email", } config = testconfig.NewRepositoryWithAccessToken(accessToken) config.SetApiEndpoint("https://test.example.org") config.SetApiVersion("☃☃☃") }) Describe("tells the user what is set in the config", func() { var output []string JustBeforeEach(func() { output = captureOutput(func() { ui := NewUI(os.Stdin) ui.ShowConfiguration(config) }) }) It("tells the user which api endpoint is set", func() {
space := models.SpaceFields{} space.Guid = "my-space-guid" space.Name = "my-space" domain := models.DomainFields{} domain.Guid = "domain-guid" domain.Name = "example.com" createdRoute := models.Route{} createdRoute.Host = "my-host" createdRoute.Guid = "my-route-guid" routeRepo := &testapi.FakeRouteRepository{ CreateInSpaceCreatedRoute: createdRoute, } ui := new(testterm.FakeUI) configRepo := testconfig.NewRepositoryWithAccessToken(configuration.TokenInfo{Username: "******"}) orgFields := models.OrganizationFields{} orgFields.Name = "my-org" configRepo.SetOrganizationFields(orgFields) cmd := NewCreateRoute(ui, configRepo, routeRepo) route, apiErr := cmd.CreateRoute("my-host", domain, space) Expect(route.Guid).To(Equal(createdRoute.Guid)) Expect(apiErr).NotTo(HaveOccurred()) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"Creating route", "my-host.example.com", "my-org", "my-space", "my-user"}, {"OK"}, })
org1 := models.Organization{} org1.Name = "Organization-1" org2 := models.Organization{} org2.Name = "Organization-2" org3 := models.Organization{} org3.Name = "Organization-3" orgRepo := &testapi.FakeOrgRepository{ Organizations: []models.Organization{org1, org2, org3}, } reqFactory := &testreq.FakeReqFactory{LoginSuccess: true} tokenInfo := configuration.TokenInfo{Username: "******"} config := testconfig.NewRepositoryWithAccessToken(tokenInfo) ui := callListOrgs(config, reqFactory, orgRepo) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"Getting orgs as my-user"}, {"Organization-1"}, {"Organization-2"}, {"Organization-3"}, }) }) It("TestListNoOrgs", func() { orgs := []models.Organization{} orgRepo := &testapi.FakeOrgRepository{ Organizations: orgs,