config      rainmaker.Config
		path, token string
		list        rainmaker.OrganizationsList
	)

	BeforeEach(func() {
		config = rainmaker.Config{
			Host: fakeCloudController.URL(),
		}
		path = "/v2/organizations"
		token = "token"
		query := url.Values{
			"page":             {"1"},
			"results-per-page": {"2"},
		}
		list = rainmaker.NewOrganizationsList(config, rainmaker.NewRequestPlan(path, query))
	})

	Describe("Create", func() {
		It("adds an organization to the list", func() {
			org, err := list.Create(rainmaker.Organization{
				GUID: "org-123",
			}, token)
			Expect(err).NotTo(HaveOccurred())
			Expect(org.GUID).To(Equal("org-123"))

			err = list.Fetch(token)
			Expect(err).NotTo(HaveOccurred())
			Expect(list.Organizations).To(HaveLen(1))
			Expect(list.Organizations[0].GUID).To(Equal("org-123"))
		})
Beispiel #2
0
var _ = Describe("UsersList", func() {
	var config rainmaker.Config
	var path, token string
	var list rainmaker.UsersList

	BeforeEach(func() {
		config = rainmaker.Config{
			Host: fakeCloudController.URL(),
		}
		path = "/v2/users"
		token = "token"
		query := url.Values{}
		query.Add("results-per-page", "2")
		query.Add("page", "1")
		list = rainmaker.NewUsersList(config, rainmaker.NewRequestPlan(path, query))
	})

	Describe("Create", func() {
		It("adds a user to the list", func() {
			user, err := list.Create(rainmaker.User{GUID: "user-123"}, token)
			Expect(err).NotTo(HaveOccurred())
			Expect(user.GUID).To(Equal("user-123"))

			err = list.Fetch(token)
			Expect(err).NotTo(HaveOccurred())
			Expect(list.Users).To(HaveLen(1))
			Expect(list.Users[0].GUID).To(Equal("user-123"))
		})
	})
Beispiel #3
0
		path, token string
		page        rainmaker.Page
	)

	BeforeEach(func() {
		config = rainmaker.Config{
			Host: fakeCloudController.URL(),
		}

		path = "/v2/users"
		token = "token"
		query := url.Values{
			"results-per-page": {"2"},
			"page":             {"1"},
		}
		page = rainmaker.NewPage(config, rainmaker.NewRequestPlan(path, query))
	})

	Describe("Next", func() {
		BeforeEach(func() {
			usersService := rainmaker.NewUsersService(config)

			_, err := usersService.Create("user-123", token)
			Expect(err).NotTo(HaveOccurred())

			_, err = usersService.Create("user-456", token)
			Expect(err).NotTo(HaveOccurred())

			_, err = usersService.Create("user-789", token)
			Expect(err).NotTo(HaveOccurred())
		})
		config      rainmaker.Config
		path, token string
		list        rainmaker.SpacesList
		orgGUID     string
	)

	BeforeEach(func() {
		config = rainmaker.Config{
			Host: fakeCloudController.URL(),
		}
		path = "/v2/spaces"
		token = "token"
		query := url.Values{}
		query.Add("results-per-page", "2")
		query.Add("page", "1")
		list = rainmaker.NewSpacesList(config, rainmaker.NewRequestPlan(path, query))

		orgGUID = "org-abc"
		fakeCloudController.Organizations.Add(domain.Organization{
			GUID:   orgGUID,
			Spaces: domain.NewSpaces(),
		})
	})

	AfterEach(func() {
		fakeCloudController.Organizations.Delete(orgGUID)
	})

	Describe("Create", func() {
		It("adds a space to the list", func() {
			space, err := list.Create(rainmaker.Space{
		path, token string
		list        rainmaker.ApplicationsList
		space       rainmaker.Space
	)

	BeforeEach(func() {
		config = rainmaker.Config{
			Host: fakeCloudController.URL(),
		}
		path = "/v2/apps"
		token = "token"
		query := url.Values{
			"page":             {"1"},
			"results-per-page": {"2"},
		}
		list = rainmaker.NewApplicationsList(config, rainmaker.NewRequestPlan(path, query))

		client = rainmaker.NewClient(config)
		org, err := client.Organizations.Create("some-org-name", token)
		Expect(err).NotTo(HaveOccurred())

		space, err = client.Spaces.Create("some-space-name", org.GUID, token)
		Expect(err).NotTo(HaveOccurred())
	})

	Context("pagination", func() {
		var (
			app1 rainmaker.Application
			app2 rainmaker.Application
			app3 rainmaker.Application
		)