Esempio n. 1
0
					userFields := models.UserFields{Guid: "the-user-guid", Username: "******"}
					userRequirement.GetUserReturns(userFields)
				})

				It("tells the user it is removing the role", func() {
					cmd.Execute(flagContext)
					Expect(ui.Outputs).To(ContainSubstrings(
						[]string{"Removing role", "SpaceManager", "the-user-name", "the-org", "the-user-name"},
						[]string{"OK"},
					))
				})

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

				Context("when the call to CC fails", func() {
					BeforeEach(func() {
						userRepo.UnsetSpaceRoleByGuidReturns(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"},