Ejemplo n.º 1
0
				},
				Resources: atc.ResourceConfigs{configResource},
			}

			fakeDB.GetConfigReturns(config, db.ConfigVersion(1), nil)
		})

		It("returns not found if the resource cannot be found in the config", func() {
			_, err := FetchTemplateData(fakeDB, "not-a-resource-name")
			Ω(err).Should(HaveOccurred())
			Ω(err).Should(MatchError(ErrResourceConfigNotFound))
		})

		Context("when the resource history lookup returns an error", func() {
			BeforeEach(func() {
				fakeDB.GetResourceHistoryReturns(nil, errors.New("disaster"))
			})

			It("returns an error if the resource's history could not be retreived", func() {
				_, err := FetchTemplateData(fakeDB, "resource-name")
				Ω(err).Should(HaveOccurred())
			})
		})

		Context("when the resource history lookup returns history", func() {

			Context("when the resource lookup returns an error", func() {
				BeforeEach(func() {
					fakeDB.GetResourceReturns(db.SavedResource{}, errors.New("disaster"))
				})