Fix errors when fromItem is not provided

This commit is contained in:
Arnau B
2020-12-09 13:59:10 +01:00
parent 8de7fe537a
commit 87501276ce
10 changed files with 69 additions and 73 deletions

View File

@@ -191,7 +191,7 @@ func TestMain(m *testing.M) {
// Swagger
router := swagger.NewRouter().WithSwaggerFromFile("./swagger.yml")
// HistoryDB
pass := os.Getenv("POSTGRES_PASS")
pass := "yourpasswordhere" // os.Getenv("POSTGRES_PASS")
database, err := db.InitSQLDB(5432, "localhost", "hermez", pass, "hermez")
if err != nil {
@@ -456,15 +456,8 @@ func doGoodReqPaginated(
for {
// Calculate fromItem
iterPath := path
if firstIte {
if order == historydb.OrderDesc {
// Fetch first item in reverse order
iterPath += "99999" // Asumption that for testing there won't be any itemID > 99999
} else {
iterPath += "0"
}
} else {
iterPath += strconv.Itoa(int(next))
if !firstIte {
iterPath += "&fromItem=" + strconv.Itoa(int(next))
}
// Call API to get this iteration items
iterStruct = iterStruct.New()