Exemple #1
0
		It("should fail with usage when provided any arguments", func() {
			requirementsFactory.LoginSuccess = true
			Expect(runCommand("blahblah")).To(BeFalse())
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Context("when logged in and an org is targeted", func() {
		BeforeEach(func() {
			space := models.Space{}
			space.Name = "space1"
			space2 := models.Space{}
			space2.Name = "space2"
			space3 := models.Space{}
			space3.Name = "space3"
			spaceRepo.Spaces = []models.Space{space, space2, space3}
			requirementsFactory.LoginSuccess = true
			requirementsFactory.TargetedOrgSuccess = true
		})

		It("lists all of the spaces", func() {
			runCommand()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Getting spaces in org", "my-org", "my-user"},
				[]string{"space1"},
				[]string{"space2"},
				[]string{"space3"},
			))
		})
							runCommand("source-app", "target-app")

							Expect(ui.Outputs).To(ContainSubstrings(
								[]string{"FAILED"},
								[]string{"could not find target app"},
							))
						})
					})
				})

				Describe("when a space is provided, but not an org", func() {
					It("send the correct target appplication for the current org and target space", func() {
						spaceRepo.Spaces = []models.Space{
							{
								SpaceFields: models.SpaceFields{
									Name: "space-name",
									Guid: "model-space-guid",
								},
							},
						}

						runCommand("-s", "space-name", "source-app", "target-app")

						targetAppName, spaceGuid := appRepo.ReadFromSpaceArgsForCall(0)
						Expect(targetAppName).To(Equal("target-app"))
						Expect(spaceGuid).To(Equal("model-space-guid"))

						Expect(ui.Outputs).To(ContainSubstrings(
							[]string{"Copying source from app", "source-app", "to target app", "target-app", "in org my-org / space space-name as my-user..."},
							[]string{"Note: this may take some time"},
							[]string{"OK"},
						))
Exemple #3
0
			orgRepo.FindByNameOrganization = org

			callTarget([]string{"-o", "my-organization"})

			Expect(orgRepo.FindByNameName).To(Equal("my-organization"))
			Expect(ui.ShowConfigurationCalled).To(BeTrue())

			Expect(config.OrganizationFields().Guid).To(Equal("my-organization-guid"))
		})

		It("updates the space in the config", func() {
			space := models.Space{}
			space.Name = "my-space"
			space.Guid = "my-space-guid"

			spaceRepo.Spaces = []models.Space{space}
			spaceRepo.FindByNameSpace = space

			callTarget([]string{"-s", "my-space"})

			Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
			Expect(config.SpaceFields().Guid).To(Equal("my-space-guid"))
			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("updates both the organization and the space in the config", func() {
			org := models.Organization{}
			org.Name = "my-organization"
			org.Guid = "my-organization-guid"
			orgRepo.Organizations = []models.Organization{org}
Exemple #4
0
					models.SpaceQuota{
						Name:                    "quota-name",
						Guid:                    "quota-guid",
						MemoryLimit:             1024,
						InstanceMemoryLimit:     512,
						RoutesLimit:             111,
						ServicesLimit:           222,
						NonBasicServicesAllowed: true,
						OrgGuid:                 "my-org-guid",
					}, nil)

				spaceRepo.Spaces = []models.Space{
					models.Space{
						SpaceFields: models.SpaceFields{
							Name: "my-space",
							Guid: "my-space-guid",
						},
						SpaceQuotaGuid: "",
					},
				}
			})

			Context("when the space quota was not previously assigned to a space", func() {
				It("associates the provided space with the provided space quota", func() {
					spaceGuid, quotaGuid := quotaRepo.AssociateSpaceWithQuotaArgsForCall(0)

					Expect(spaceGuid).To(Equal("my-space-guid"))
					Expect(quotaGuid).To(Equal("quota-guid"))
					Expect(ui.Outputs).To(ContainSubstrings(
						[]string{"Assigning space quota", "to space", "my-user"},
						[]string{"OK"},
Exemple #5
0
				org1.Name = "some-org"

				org2 = models.Organization{}
				org2.Guid = "my-new-org-guid"
				org2.Name = "my-new-org"

				space1 := models.Space{}
				space1.Guid = "my-space-guid"
				space1.Name = "my-space"

				space2 = models.Space{}
				space2.Guid = "some-space-guid"
				space2.Name = "some-space"

				orgRepo.ListOrgsReturns([]models.Organization{org1, org2}, nil)
				spaceRepo.Spaces = []models.Space{space1, space2}
			})

			It("lets the user select an org and space by number", func() {
				orgRepo.FindByNameReturns(org2, nil)
				OUT_OF_RANGE_CHOICE := "3"
				ui.Inputs = []string{"api.example.com", "*****@*****.**", "password", OUT_OF_RANGE_CHOICE, "2", OUT_OF_RANGE_CHOICE, "1"}

				l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
				testcmd.RunCommand(l, Flags, nil)

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Select an org"},
					[]string{"1. some-org"},
					[]string{"2. my-new-org"},
					[]string{"Select a space"},