Ejemplo n.º 1
0
											VersionedResource: db.VersionedResource{
												Resource: "resource-name",
											},
										},
									},
								}

								fakeDB.GetResourceHistoryCursorReturns(history, true, nil)
							})

							Context("when the passed in id is 0", func() {
								It("uses the max id to pull history", func() {
									templateData, err := FetchTemplateData(fakeDB, false, "resource-name", 0, false)
									Expect(err).NotTo(HaveOccurred())

									Expect(fakeDB.GetResourceHistoryCursorCallCount()).To(Equal(1))
									resourceName, startingID, searchUpwards, numResults := fakeDB.GetResourceHistoryCursorArgsForCall(0)
									Expect(resourceName).To(Equal("resource-name"))
									Expect(startingID).To(Equal(MaxID))
									Expect(searchUpwards).To(BeFalse())
									Expect(numResults).To(Equal(100))
									Expect(templateData.PaginationData.HasPagination()).To(BeTrue())
								})
							})

							It("has the correct template data", func() {
								templateData, err := FetchTemplateData(fakeDB, authenticated, "resource-name", 0, false)
								Expect(err).NotTo(HaveOccurred())

								Expect(templateData.GroupStates).To(ConsistOf([]group.State{
									{
Ejemplo n.º 2
0
											ID: 1,
											VersionedResource: db.VersionedResource{
												Resource: "resource-name",
											},
										},
									},
								}

								fakeDB.GetResourceHistoryCursorReturns(history, false, nil)
							})

							It("does not have pagination", func() {
								templateData, err := FetchTemplateData(fakeDB, false, "resource-name", 0, false)
								Ω(err).ShouldNot(HaveOccurred())

								Ω(fakeDB.GetResourceHistoryCursorCallCount()).Should(Equal(1))
								resourceName, startingID, searchUpwards, numResults := fakeDB.GetResourceHistoryCursorArgsForCall(0)
								Ω(resourceName).Should(Equal("resource-name"))
								Ω(startingID).Should(Equal(90))
								Ω(searchUpwards).Should(BeFalse())
								Ω(numResults).Should(Equal(100))
								Ω(templateData.PaginationData.HasPagination).Should(BeFalse())
								Ω(templateData.PaginationData.HasOlder).Should(BeFalse())
								Ω(templateData.PaginationData.HasNewer).Should(BeFalse())
							})
						})

						Context("when there are more than 100 results", func() {
							const MaxID int = 150

							BeforeEach(func() {