@@ -191,27 +191,29 @@ func testPagination(t *testing.T, store driver.VaultStore) {
191
191
// test that we read everything
192
192
Expect (page ).To (BeNumerically ("==" , len (item .matcher )))
193
193
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
+ }
215
217
}
216
218
}
217
219
0 commit comments