err := service.Delete("very-bad-guid", token) Expect(err).To(BeAssignableToTypeOf(rainmaker.Error{})) }) }) }) Describe("ListUsers", func() { var ( user rainmaker.User space rainmaker.Space ) BeforeEach(func() { var err error user, err = rainmaker.NewUsersService(config).Create("user-abc", token) Expect(err).NotTo(HaveOccurred()) _, err = rainmaker.NewUsersService(config).Create("user-xyz", token) Expect(err).NotTo(HaveOccurred()) space, err = service.Create(spaceName, org1.GUID, token) Expect(err).NotTo(HaveOccurred()) err = space.Developers.Associate(user.GUID, token) Expect(err).NotTo(HaveOccurred()) }) It("returns the users belonging to the space", func() { list, err := service.ListUsers(space.GUID, token) Expect(err).NotTo(HaveOccurred())
import ( "github.com/pivotal-cf-experimental/rainmaker" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("UsersService", func() { var token string var service *rainmaker.UsersService BeforeEach(func() { token = "token" service = rainmaker.NewUsersService(rainmaker.Config{ Host: fakeCloudController.URL(), }) }) Describe("Create/Get", func() { It("creates a new user record in cloud controller and allows it to be fetched", func() { userGUID := "new-user-guid" user, err := service.Create(userGUID, token) Expect(err).NotTo(HaveOccurred()) Expect(user.GUID).To(Equal(userGUID)) fetchedUser, err := service.Get(userGUID, token) Expect(err).NotTo(HaveOccurred()) Expect(fetchedUser.GUID).To(Equal(userGUID)) })
Context("when the organization does not exist", func() { It("returns an error", func() { _, err := service.ListSpaces("org-does-not-exist", token) Expect(err).To(BeAssignableToTypeOf(rainmaker.NotFoundError{})) }) }) }) }) Context("when listing related users", func() { var user1, user2, user3 rainmaker.User BeforeEach(func() { var err error usersService := rainmaker.NewUsersService(config) user1, err = usersService.Create("user-123", token) Expect(err).NotTo(HaveOccurred()) user2, err = usersService.Create("user-456", token) Expect(err).NotTo(HaveOccurred()) user3, err = usersService.Create("user-789", token) Expect(err).NotTo(HaveOccurred()) }) Describe("ListUsers", func() { BeforeEach(func() { err := organization.Users.Associate(user1.GUID, token) Expect(err).NotTo(HaveOccurred())