Ejemplo n.º 1
0
					))
				})

				It("sets the role using the GUID", func() {
					cmd.Execute(flagContext)
					Expect(userRepo.SetSpaceRoleByGuidCallCount()).To(Equal(1))
					actualUserGUID, actualSpaceGUID, actualOrgGUID, actualRole := userRepo.SetSpaceRoleByGuidArgsForCall(0)
					Expect(actualUserGUID).To(Equal("the-user-guid"))
					Expect(actualSpaceGUID).To(Equal("the-space-guid"))
					Expect(actualOrgGUID).To(Equal("the-org-guid"))
					Expect(actualRole).To(Equal("SpaceManager"))
				})

				Context("when the call to CC fails", func() {
					BeforeEach(func() {
						userRepo.SetSpaceRoleByGuidReturns(errors.New("user-repo-error"))
					})

					It("panics and prints a failure message", func() {
						Expect(func() { cmd.Execute(flagContext) }).To(Panic())
						Expect(ui.Outputs).To(BeInDisplayOrder(
							[]string{"FAILED"},
							[]string{"user-repo-error"},
						))
					})
				})
			})

			Context("when the UserRequirement returns a user without a GUID", func() {
				BeforeEach(func() {
					requirementsFactory.UserFields = models.UserFields{Username: "******"}