func (s *Server) DisableResourceVersion(pipelineDB db.PipelineDB) http.Handler { logger := s.logger.Session("disable-resource-version") return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resourceID, err := strconv.Atoi(rata.Param(r, "resource_version_id")) if err != nil { w.WriteHeader(http.StatusBadRequest) return } err = pipelineDB.DisableVersionedResource(resourceID) if err != nil { logger.Error("failed-to-disable-versioned-resource", err) w.WriteHeader(http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) }) }
pipelineDB.SaveBuildInput(build.ID, db.BuildInput{ Name: "some-input", VersionedResource: expectedVersions[9].VersionedResource, FirstOccurrence: true, }) }) It("returns the metadata in the version history", func() { historyPage, _, err := pipelineDB.GetResourceVersions("some-resource", db.Page{Limit: 1}) Expect(err).ToNot(HaveOccurred()) Expect(historyPage).To(Equal([]db.SavedVersionedResource{expectedVersions[9]})) }) }) Context("when a version is disabled", func() { BeforeEach(func() { pipelineDB.DisableVersionedResource(10) expectedVersions[9].Enabled = false }) It("returns a disabled version", func() { historyPage, _, err := pipelineDB.GetResourceVersions("some-resource", db.Page{Limit: 1}) Expect(err).ToNot(HaveOccurred()) Expect(historyPage).To(Equal([]db.SavedVersionedResource{expectedVersions[9]})) }) }) }) })