本文整理匯總了Golang中github.com/concourse/atc/db.PipelineDB.DisableVersionedResource方法的典型用法代碼示例。如果您正苦於以下問題:Golang PipelineDB.DisableVersionedResource方法的具體用法?Golang PipelineDB.DisableVersionedResource怎麽用?Golang PipelineDB.DisableVersionedResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/concourse/atc/db.PipelineDB
的用法示例。
在下文中一共展示了PipelineDB.DisableVersionedResource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DisableResourceVersion
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)
})
}
示例2:
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]}))
})
})
})
})