func NewCloudController() *CloudController { cc := &CloudController{ Organizations: domain.NewOrganizations(), Spaces: domain.NewSpaces(), Users: domain.NewUsers(), ServiceInstances: domain.NewServiceInstances(), Applications: domain.NewApplications(), } router := mux.NewRouter() router.Handle("/v2/organizations{anything:.*}", organizations.NewRouter(cc.Organizations, cc.Users)) router.Handle("/v2/spaces{anything:.*}", spaces.NewRouter(cc.Organizations, cc.Spaces, cc.Users)) router.Handle("/v2/users{anything:.*}", users.NewRouter(cc.Users, cc.Spaces)) router.Handle("/v2/service_instances{anything:.*}", serviceinstances.NewRouter(cc.ServiceInstances)) router.Handle("/v2/apps{anything:.*}", applications.NewRouter(cc.Applications)) handler := cc.requireToken(router) cc.server = httptest.NewUnstartedServer(handler) return cc }
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{ GUID: "space-123", OrganizationGUID: orgGUID, }, token) Expect(err).NotTo(HaveOccurred()) Expect(space.GUID).To(Equal("space-123"))