func (m *Mother) SpaceStrategy() services.SpaceStrategy { env := NewEnvironment() uaaClient := uaa.NewZonedUAAClient(env.UAAClientID, env.UAAClientSecret, env.VerifySSL, UAAPublicKey) cloudController := cf.NewCloudController(env.CCHost, !env.VerifySSL) tokenLoader := uaa.NewTokenLoader(uaaClient) spaceLoader := services.NewSpaceLoader(cloudController) organizationLoader := services.NewOrganizationLoader(cloudController) enqueuer := m.Enqueuer() findsUserGUIDs := services.NewFindsUserGUIDs(cloudController, uaaClient) return services.NewSpaceStrategy(tokenLoader, spaceLoader, organizationLoader, findsUserGUIDs, enqueuer, m.V2Enqueuer()) }
var _ = Describe("SpaceLoader", func() { Describe("Load", func() { var ( loader services.SpaceLoader cc *mocks.CloudController ) BeforeEach(func() { cc = mocks.NewCloudController() cc.LoadSpaceCall.Returns.Space = cf.CloudControllerSpace{ GUID: "space-001", Name: "space-name", OrganizationGUID: "org-001", } loader = services.NewSpaceLoader(cc) }) It("returns the space", func() { space, err := loader.Load("space-001", "some-token") Expect(err).NotTo(HaveOccurred()) Expect(space).To(Equal(cf.CloudControllerSpace{ GUID: "space-001", Name: "space-name", OrganizationGUID: "org-001", })) Expect(cc.LoadSpaceCall.Receives.SpaceGUID).To(Equal("space-001")) Expect(cc.LoadSpaceCall.Receives.Token).To(Equal("some-token")) })