コード例 #1
0
		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"))
		})

		Context("when the space cannot be found", func() {
			It("returns an error object", func() {
				cc.LoadSpaceCall.Returns.Error = cf.NewFailure(404, "not found")

				_, err := loader.Load("missing-space", "some-token")
				Expect(err).To(Equal(services.CCNotFoundError("CloudController Failure (404): not found")))
			})
		})

		Context("when Load returns any other type of error", func() {
			It("returns a CCDownError when the error is cf.Failure", func() {
				cc.LoadSpaceCall.Returns.Error = cf.NewFailure(401, "BOOM!")

				_, err := loader.Load("space-001", "some-token")
				Expect(err).To(Equal(services.CCDownError("CloudController Failure (401): BOOM!")))
			})

			It("returns the same error for all other cases", func() {
コード例 #2
0
		It("returns the org", func() {
			org, err := loader.Load("org-001", "some-token")
			Expect(err).NotTo(HaveOccurred())
			Expect(org).To(Equal(cf.CloudControllerOrganization{
				GUID: "org-001",
				Name: "org-name",
			}))

			Expect(cc.LoadOrganizationCall.Receives.OrgGUID).To(Equal("org-001"))
			Expect(cc.LoadOrganizationCall.Receives.Token).To(Equal("some-token"))
		})

		Context("when the org cannot be found", func() {
			It("returns an error object", func() {
				cc.LoadOrganizationCall.Returns.Error = cf.NewFailure(404, "BOOM!")

				_, err := loader.Load("missing-org", "some-token")
				Expect(err).To(Equal(services.CCNotFoundError("CloudController Failure (404): BOOM!")))
			})
		})

		Context("when Load returns any other type of error", func() {
			It("returns a CCDownError when the error is cf.Failure", func() {
				cc.LoadOrganizationCall.Returns.Error = cf.NewFailure(401, "BOOM!")

				_, err := loader.Load("org-001", "some-token")
				Expect(err).To(Equal(services.CCDownError("CloudController Failure (401): BOOM!")))
			})

			It("returns the same error for all other cases", func() {