Skip to content

Commit 5d00fcf

Browse files
author
Hayim Shaul
committed
fix pagination.prev test
Signed-off-by: Hayim Shaul <[email protected]>
1 parent 2f74ad0 commit 5d00fcf

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

platform/view/services/storage/vault/vaultstore_test.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,27 +191,29 @@ func testPagination(t *testing.T, store driver.VaultStore) {
191191
// test that we read everything
192192
Expect(page).To(BeNumerically("==", len(item.matcher)))
193193

194-
// Do we want to test Prev()?
195-
// Test that Prev() work. Start by moving the pagination pointer forward
196-
// pagination = item.pagination
197-
// for page := 0; page < len(item.matcher)-1; page++ {
198-
// pagination, err = pagination.Next()
199-
// Expect(err).ToNot(HaveOccurred())
200-
// }
201-
// for page := len(item.matcher) - 1; page >= 0; page-- {
202-
// sql := common.SqlQuery{}
203-
// sql, err := interpreter.Interpret(pagination, sql)
204-
// Expect(err).ToNot(HaveOccurred())
205-
// fmt.Printf("sql (backward) = %s\n", sql.FormatQuery())
206-
// Expect(sql.FormatQuery()).To(Equal(item.sqlBackward[page]))
207-
// statuses, err := getAllTxStatuses(store, pagination)
208-
// Expect(err).ToNot(HaveOccurred())
209-
// Expect(statuses).To(item.matcher[page])
210-
// if page > 0 {
211-
// pagination, err = pagination.Prev()
212-
// Expect(err).ToNot(HaveOccurred())
213-
// }
214-
// }
194+
// Test that Prev() work. Start by advancing the pagination pointer 2 steps forward
195+
if len(item.matcher) < 2 {
196+
continue
197+
}
198+
pagination = item.pagination
199+
for page = 0; page < 2; page++ {
200+
pagination, err = pagination.Next()
201+
Expect(err).ToNot(HaveOccurred())
202+
}
203+
for ; page >= 0; page-- {
204+
sql := driver.SqlQuery{}
205+
sql.SetTable("test")
206+
sql, err := interpreter.Interpret(pagination, sql)
207+
Expect(err).ToNot(HaveOccurred())
208+
Expect(sql.FormatQuery()).To(Equal(item.sqlBackward[page]))
209+
statuses, err := getAllTxStatuses(store, sql, &pagination)
210+
Expect(err).ToNot(HaveOccurred())
211+
Expect(statuses).To(item.matcher[page])
212+
if page > 0 {
213+
pagination, err = pagination.Prev()
214+
Expect(err).ToNot(HaveOccurred())
215+
}
216+
}
215217
}
216218
}
217219

0 commit comments

Comments
 (0)