Esempio n. 1
0
		BeforeEach(func() {
			resourceName = "some-resource"
		})

		JustBeforeEach(func() {
			var err error

			request, err := http.NewRequest("GET", fmt.Sprintf("%s/api/v1/pipelines/a-pipeline/resources/%s", server.URL, resourceName), nil)
			Expect(err).NotTo(HaveOccurred())

			response, err = client.Do(request)
			Expect(err).NotTo(HaveOccurred())
		})

		It("calls to get the config from the fakePipelineDB", func() {
			Expect(fakePipelineDB.GetConfigCallCount()).To(Equal(1))
		})

		Context("when the call to get config returns an error", func() {
			BeforeEach(func() {
				fakePipelineDB.GetConfigReturns(atc.Config{}, 0, false, errors.New("disaster"))
			})

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

		Context("when the config in the database can't be found", func() {
			BeforeEach(func() {
				fakePipelineDB.GetConfigReturns(atc.Config{}, 0, false, nil)