}, Resources: atc.ResourceConfigs{configResource}, } fakeDB.GetConfigReturns(config, 1, true, nil) }) It("returns not found if the resource cannot be found in the config", func() { _, err := FetchTemplateData(fakeDB, false, "not-a-resource-name", 0, false) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(ErrResourceConfigNotFound)) }) Context("when the resource history lookup returns an error", func() { BeforeEach(func() { fakeDB.GetResourceHistoryCursorReturns(nil, false, errors.New("disaster")) }) It("returns an error if the resource's history could not be retreived", func() { _, err := FetchTemplateData(fakeDB, false, "resource-name", 0, false) Expect(err).To(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")) }) It("returns an error if the resource's history could not be retreived", func() {