Ejemplo n.º 1
0
				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})
Ejemplo n.º 2
0
				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))