本文整理汇总了Golang中github.com/concourse/atc/db.PipelineDB.SaveResourceVersions方法的典型用法代码示例。如果您正苦于以下问题:Golang PipelineDB.SaveResourceVersions方法的具体用法?Golang PipelineDB.SaveResourceVersions怎么用?Golang PipelineDB.SaveResourceVersions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/atc/db.PipelineDB
的用法示例。
在下文中一共展示了PipelineDB.SaveResourceVersions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
versions = append(versions, version)
expectedVersions = append(expectedVersions,
db.SavedVersionedResource{
ID: i + 1,
Enabled: true,
VersionedResource: db.VersionedResource{
Resource: resource.Name,
Type: resource.Type,
Version: db.Version(version),
Metadata: nil,
PipelineName: pipelineDB.GetPipelineName(),
},
})
}
err := pipelineDB.SaveResourceVersions(resource, versions)
Expect(err).NotTo(HaveOccurred())
})
Context("when there are no versions to be found", func() {
It("returns the versions, with previous/next pages", func() {
historyPage, pagination, err := pipelineDB.GetResourceVersions("nope", db.Page{})
Expect(err).ToNot(HaveOccurred())
Expect(historyPage).To(Equal([]db.SavedVersionedResource{}))
Expect(pagination).To(Equal(db.Pagination{}))
})
})
Context("with no since/until", func() {
It("returns the first page, with the given limit, and a next page", func() {
historyPage, pagination, err := pipelineDB.GetResourceVersions("some-resource", db.Page{Limit: 2})
示例2:
pipelineDB, err = pipelineDBFactory.BuildDefault()
Ω(err).ShouldNot(HaveOccurred())
resourceConfig := atc.ResourceConfig{
Name: "resource-name",
Type: "some-type",
Source: atc.Source{},
}
var resourceVersions []atc.Version
for i := 0; i < 104; i++ {
resourceVersions = append(resourceVersions, atc.Version{"version": strconv.Itoa(i)})
}
pipelineDB.SaveResourceVersions(resourceConfig, resourceVersions)
})
It("there is pagination", func() {
// homepage -> resource detail
Expect(page.Navigate(homepage())).To(Succeed())
Eventually(page.FindByLink("resource-name")).Should(BeFound())
Expect(page.FindByLink("resource-name").Click()).To(Succeed())
// resource detail -> paused resource detail
Expect(page).Should(HaveURL(withPath("/resources/resource-name")))
Expect(page.Find("h1")).To(HaveText("resource-name"))
Expect(page.All(".pagination").Count()).Should(Equal(2))
Expect(page.Find(".resource-versions")).Should(BeFound())
Expect(page.All(".resource-versions li").Count()).Should(Equal(100))