Ejemplo n.º 1
0
		})
	})

	Describe("when the user provides fewer than two args", func() {
		It("fails with usage", func() {
			callRenameSpace([]string{"foo"})
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Describe("when the user is logged in and has provided an old and new space name", func() {
		BeforeEach(func() {
			space := models.Space{}
			space.Name = "the-old-space-name"
			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))
		})
Ejemplo n.º 2
0
			runCommand("my-space")
			Expect(ui.FailedWithUsage).To(BeTrue())
		})
	})

	Context("when logged in, targeted a space and given a domain that exists", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
			requirementsFactory.TargetedOrgSuccess = true
			requirementsFactory.Domain = models.DomainFields{
				Guid: "domain-guid",
				Name: "example.com",
			}
			requirementsFactory.Space = models.Space{SpaceFields: models.SpaceFields{
				Guid: "my-space-guid",
				Name: "my-space",
			}}
		})

		It("creates routes, obviously", func() {
			runCommand("-n", "host", "my-space", "example.com")

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Creating route", "host.example.com", "my-org", "my-space", "my-user"},
				[]string{"OK"},
			))

			Expect(routeRepo.CreateInSpaceHost).To(Equal("host"))
			Expect(routeRepo.CreateInSpaceDomainGuid).To(Equal("domain-guid"))
			Expect(routeRepo.CreateInSpaceSpaceGuid).To(Equal("my-space-guid"))
		})