Esempio n. 1
0
		spaceRepo.CreateReturns(models.Space{}, errors.NewHTTPError(400, errors.SpaceNameTaken, "Space already exists"))
		runCommand("my-space")

		Expect(ui.Outputs()).To(ContainSubstrings(
			[]string{"Creating space", "my-space"},
			[]string{"OK"},
		))
		Expect(ui.WarnOutputs).To(ContainSubstrings([]string{"my-space", "already exists"}))
		Expect(ui.Outputs()).ToNot(ContainSubstrings(
			[]string{"Assigning", "my-user", "my-space", "SpaceManager"},
		))

		Expect(spaceRepo.CreateCallCount()).To(Equal(1))
		actualSpaceName, _, _ := spaceRepo.CreateArgsForCall(0)
		Expect(actualSpaceName).To(Equal("my-space"))
		Expect(userRepo.SetSpaceRoleByGUIDCallCount()).To(BeZero())
	})

	Context("when the -o flag is provided", func() {
		It("creates a space within that org", func() {
			org := models.Organization{
				OrganizationFields: models.OrganizationFields{
					Name: "other-org",
					GUID: "org-guid-1",
				}}
			orgRepo.FindByNameReturns(org, nil)

			runCommand("-o", "other-org", "my-space")

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"Creating space", "my-space", "other-org", "my-user"},