defaultOrgRepo.FindByNameNotFound = true ui := callCreateSpace([]string{"-o", "cool-organization", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"FAILED"}, {"cool-organization", "does not exist"}, }) Expect(defaultSpaceRepo.CreateSpaceName).To(Equal("")) }) It("TestCreateSpaceInOrgWhenErrorFindingOrg", func() { resetSpaceDefaults() defaultOrgRepo.FindByNameErr = true ui := callCreateSpace([]string{"-o", "cool-organization", "my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"FAILED"}, {"error"}, }) Expect(defaultSpaceRepo.CreateSpaceName).To(Equal("")) }) It("TestCreateSpaceWhenItAlreadyExists", func() { resetSpaceDefaults() defaultSpaceRepo.CreateSpaceExists = true ui := callCreateSpace([]string{"my-space"}, defaultReqFactory, defaultSpaceRepo, defaultOrgRepo, defaultUserRepo)
orgRepo.Organizations = []models.Organization{org} orgRepo.FindByNameOrganization = org ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo) Expect(orgRepo.FindByNameName).To(Equal("my-organization")) Expect(ui.ShowConfigurationCalled).To(BeTrue()) Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid")) }) It("TestTargetOrganizationWhenUserDoesNotHaveAccess", func() { orgs := []models.Organization{} orgRepo.Organizations = orgs orgRepo.FindByNameErr = true ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo) testassert.SliceContains(ui.Outputs, testassert.Lines{{"FAILED"}}) }) It("TestTargetOrganizationWhenOrgNotFound", func() { orgRepo.FindByNameNotFound = true ui := callTarget([]string{"-o", "my-organization"}, reqFactory, config, orgRepo, spaceRepo) testassert.SliceContains(ui.Outputs, testassert.Lines{ {"FAILED"}, {"my-organization", "not found"}, }) })