Example #1
0
				}, 1, true, nil)
			})

			Context("when the resource cannot be found in the config", func() {
				It("returns a 404", func() {
					Expect(response.StatusCode).To(Equal(http.StatusNotFound))
				})
			})

			Context("when the resource is found in the config", func() {
				BeforeEach(func() {
					resourceName = "resource-1"
				})

				It("looks it up in the database", func() {
					Expect(fakePipelineDB.GetResourceCallCount()).To(Equal(1))
					Expect(fakePipelineDB.GetResourceArgsForCall(0)).To(Equal("resource-1"))
				})

				Context("when the call to the db returns an error", func() {
					BeforeEach(func() {
						fakePipelineDB.GetResourceReturns(db.SavedResource{}, errors.New("Oh no!"))
					})

					It("returns a 500 error", func() {
						Expect(response.StatusCode).To(Equal(http.StatusInternalServerError))
					})
				})

				Context("when the call to get a resource succeeds", func() {
					BeforeEach(func() {