Example #1
0
		Context("when cc api verson is >= 2.21.0", func() {
			BeforeEach(func() {
				configRepo.SetApiVersion("2.22.0")
			})

			It("calls ListUsersInSpaceForRoleWithNoUAA()", func() {
				runCommand("my-org", "my-sapce")

				Expect(userRepo.ListUsersInSpaceForRoleWithNoUAACallCount()).To(BeNumerically(">=", 1))
				Expect(userRepo.ListUsersInSpaceForRoleCallCount()).To(Equal(0))
			})

			It("fails with an error when user network call fails", func() {
				userRepo.ListUsersInSpaceForRoleWithNoUAAStub = func(string, role string) ([]models.UserFields, error) {
					if role == "SpaceManager" {
						return []models.UserFields{}, errors.New("internet badness occurred")
					}
					return []models.UserFields{}, nil
				}
				runCommand("my-org", "my-space")
				Expect(ui.Outputs).To(BeInDisplayOrder(
					[]string{"Getting users in org", "Org1"},
					[]string{"internet badness occurred"},
				))
			})
		})

		Context("when cc api verson is < 2.21.0", func() {
			It("calls ListUsersInSpaceForRole()", func() {
				configRepo.SetApiVersion("2.20.0")
				runCommand("my-org", "my-space")