Exemple #1
0
			space.Guid = "the-old-space-guid"
			requirementsFactory.Space = space
		})

		It("renames a space", func() {
			originalSpaceName := configRepo.SpaceFields().Name
			callRenameSpace([]string{"the-old-space-name", "my-new-space"})

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Renaming space", "the-old-space-name", "my-new-space", "my-org", "my-user"},
				[]string{"OK"},
			))

			Expect(spaceRepo.RenameSpaceGuid).To(Equal("the-old-space-guid"))
			Expect(spaceRepo.RenameNewName).To(Equal("my-new-space"))
			Expect(configRepo.SpaceFields().Name).To(Equal(originalSpaceName))
		})

		Describe("renaming the space the user has targeted", func() {
			BeforeEach(func() {
				configRepo.SetSpaceFields(requirementsFactory.Space.SpaceFields)
			})

			It("renames the targeted space", func() {
				callRenameSpace([]string{"the-old-space-name", "my-new-space-name"})
				Expect(configRepo.SpaceFields().Name).To(Equal("my-new-space-name"))
			})
		})
	})
})
Exemple #2
0
			space.Guid = "my-space-guid"
			spaceRepo.Spaces = []models.Space{space}

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

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

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

			Expect(ui.ShowConfigurationCalled).To(BeTrue())
		})

		It("only updates the organization in the config when the space can't be found", func() {
			config.SetSpaceFields(models.SpaceFields{})

			org := models.Organization{}
			org.Name = "my-organization"
			org.Guid = "my-organization-guid"
			orgRepo.Organizations = []models.Organization{org}

			spaceRepo.FindByNameErr = true

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

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

			Expect(spaceRepo.FindByNameName).To(Equal("my-space"))
			Expect(config.SpaceFields().Guid).To(Equal(""))
Exemple #3
0
			requirementsFactory.ApiEndpointSuccess = false

			testcmd.RunCommand(cmd, []string{}, requirementsFactory)
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Context("when the user is logged in", func() {
		BeforeEach(func() {
			config = testconfig.NewRepositoryWithDefaults()
		})

		Context("when the user has a space targeted", func() {
			BeforeEach(func() {
				config.SetSpaceFields(models.SpaceFields{
					Guid: "the-space-guid",
					Name: "the-space-name",
				})
			})

			It("lists all of the service offerings for the space", func() {
				serviceRepo := &testapi.FakeServiceRepo{}
				serviceRepo.GetServiceOfferingsForSpaceReturns.ServiceOfferings = fakeServiceOfferings
				cmd := NewMarketplaceServices(ui, config, serviceRepo)
				testcmd.RunCommand(cmd, []string{}, requirementsFactory)

				Expect(serviceRepo.GetServiceOfferingsForSpaceArgs.SpaceGuid).To(Equal("the-space-guid"))

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Getting services from marketplace in org", "my-org", "the-space-name", "my-user"},
					[]string{"OK"},
					[]string{"service", "plans", "description"},
Exemple #4
0
	Describe("updating the endpoints", func() {
		Context("when the API request is successful", func() {
			var (
				org   models.OrganizationFields
				space models.SpaceFields
			)
			BeforeEach(func() {
				org.Name = "my-org"
				org.Guid = "my-org-guid"

				space.Name = "my-space"
				space.Guid = "my-space-guid"

				config.SetOrganizationFields(org)
				config.SetSpaceFields(space)
				testServerFn = validApiInfoEndpoint
			})

			It("stores the data from the /info api in the config", func() {
				repo.UpdateEndpoint(testServer.URL)

				Expect(config.AccessToken()).To(Equal(""))
				Expect(config.AuthenticationEndpoint()).To(Equal("https://login.example.com"))
				Expect(config.LoggregatorEndpoint()).To(Equal("wss://loggregator.foo.example.org:4443"))
				Expect(config.ApiEndpoint()).To(Equal(testServer.URL))
				Expect(config.ApiVersion()).To(Equal("42.0.0"))
				Expect(config.HasOrganization()).To(BeFalse())
				Expect(config.HasSpace()).To(BeFalse())
			})
Exemple #5
0
				BeforeEach(func() {
					config.SetOrganizationFields(models.OrganizationFields{
						Name: "org-name",
						Guid: "org-guid",
					})
				})

				It("tells the user which org is targeted", func() {
					Expect(output).To(ContainSubstrings([]string{"Org:", "org-name"}))
				})
			})

			Context("when a space is targeted", func() {
				BeforeEach(func() {
					config.SetSpaceFields(models.SpaceFields{
						Name: "my-space",
						Guid: "space-guid",
					})
				})

				It("tells the user which space is targeted", func() {
					Expect(output).To(ContainSubstrings([]string{"Space:", "my-space"}))
				})
			})
		})

		It("prompts the user to target an org and space when no org or space is targeted", func() {
			output := io_helpers.CaptureOutput(func() {
				ui := NewUI(os.Stdin)
				ui.ShowConfiguration(config)
			})
Exemple #6
0
		ui.Inputs = []string{"yes"}
		runCommand("space-to-delete")

		Expect(ui.Prompts).To(ContainSubstrings([]string{"Really delete the space space-to-delete"}))
		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"Deleting space", "space-to-delete", "my-org", "my-user"},
			[]string{"OK"},
		))
		Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
		Expect(config.HasSpace()).To(Equal(true))
	})

	It("does not prompt when the -f flag is given", func() {
		runCommand("-f", "space-to-delete")

		Expect(ui.Prompts).To(BeEmpty())
		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"Deleting", "space-to-delete"},
			[]string{"OK"},
		))
		Expect(spaceRepo.DeletedSpaceGuid).To(Equal("space-to-delete-guid"))
	})

	It("clears the space from the config, when deleting the space currently targeted", func() {
		config.SetSpaceFields(space.SpaceFields)
		runCommand("-f", "space-to-delete")

		Expect(config.HasSpace()).To(Equal(false))
	})
})