Ejemplo n.º 1
0
	})

	var recorder *httptest.ResponseRecorder

	JustBeforeEach(func() {
		recorder = httptest.NewRecorder()
		req, err := http.NewRequest("GET", "http://concourse.example.com/", nil)
		Ω(err).ShouldNot(HaveOccurred())

		handler.ServeHTTP(recorder, req)
	})

	Context("when the pipeline lookup fails", func() {
		Context("when there is an unexpected error", func() {
			BeforeEach(func() {
				pipelineDBFactory.BuildDefaultReturns(nil, errors.New("nope"))
			})

			It("returns an internal server error", func() {
				Ω(recorder.Code).Should(Equal(http.StatusInternalServerError))
			})
		})

		Context("because there are no pipelines", func() {
			BeforeEach(func() {
				pipelineDBFactory.BuildDefaultReturns(nil, db.ErrNoPipelines)
			})

			It("is successful", func() {
				Ω(recorder.Code).Should(Equal(http.StatusOK))
			})