Example #1
0
			BeforeEach(func() {
				userFields := models.UserFields{Guid: "the-user-guid", Username: "******"}
				userRequirement.GetUserReturns(userFields)
			})

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

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

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