Ejemplo n.º 1
0
			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() {
				cc.LoadSpaceCall.Returns.Error = errors.New("BOOM!")

				_, err := loader.Load("space-001", "some-token")
				Expect(err).To(Equal(errors.New("BOOM!")))
			})
		})
	})
})
Ejemplo n.º 2
0
		writer.Write(recorder, postal.UAAScopesError("UAA Scopes Error: Client does not have authority to register critical notifications."))

		unprocessableEntity := 422
		Expect(recorder.Code).To(Equal(unprocessableEntity))

		body := make(map[string]interface{})
		err := json.Unmarshal(recorder.Body.Bytes(), &body)
		if err != nil {
			panic(err)
		}

		Expect(body["errors"]).To(ContainElement("UAA Scopes Error: Client does not have authority to register critical notifications."))
	})

	It("returns a 502 when CloudController fails to respond", func() {
		writer.Write(recorder, services.CCDownError("Bad things happened!"))

		Expect(recorder.Code).To(Equal(http.StatusBadGateway))

		body := make(map[string]interface{})
		err := json.Unmarshal(recorder.Body.Bytes(), &body)
		if err != nil {
			panic(err)
		}

		Expect(body["errors"]).To(ContainElement("Bad things happened!"))
	})

	It("returns a 502 when UAA fails to respond", func() {
		writer.Write(recorder, postal.UAADownError("Whoops!"))