var _ = Describe("LoadSpace", func() { var CCServer *httptest.Server var cc cf.CloudController BeforeEach(func() { CCServer = httptest.NewServer(SpacesEndpoint) cc = cf.NewCloudController(CCServer.URL, false) }) AfterEach(func() { CCServer.Close() }) It("loads the space from cloud controller", func() { space, err := cc.LoadSpace("space-guid", "notification-token") if err != nil { panic(err) } Expect(space.GUID).To(Equal("space-guid")) Expect(space.Name).To(Equal("duh space")) Expect(space.OrganizationGUID).To(Equal("first-rate")) }) It("returns a 404 error code when the space cannot be found", func() { _, err := cc.LoadSpace("banana", "notification-token") Expect(err).To(BeAssignableToTypeOf(cf.Failure{})) Expect(err.(cf.Failure).Code).To(Equal(404)) Expect(err.Error()).To(Equal(`CloudController Failure (404): Space "banana" could not be found`)) })