cancel bookings should work without comparing ListBookings result
In cancel_all_bookings mode, deletes any bookings from previous runs.
diff --git a/api/api.go b/api/api.go
index 25cbf59..7b0a202 100644
--- a/api/api.go
+++ b/api/api.go
@@ -273,7 +273,6 @@
// ListBookings calls the maps booking ListBookings rpc and compares the return with all input bookings.
func ListBookings(tB Bookings, conn *HTTPConnection) (Bookings, error) {
- var out Bookings
reqPB := &mpb.ListBookingsRequest{
UserId: userID,
}
@@ -291,12 +290,16 @@
}
gB := Bookings(resp.GetBookings())
- if len(gB) != len(tB) {
- return nil, fmt.Errorf("number of bookings differ, ListBookings invalid. Got: %d, Want: %d. Abandoning all bookings from this flow", len(gB), len(tB))
+ if len(tB) == 0 {
+ log.Printf("ListBookings returning %d found bookings", len(gB))
+ return gB, nil
}
-
+ if len(gB) != len(tB) {
+ log.Printf("ListBookings number of bookings differed unexpectedly. Got: %d, Want: %d.", len(gB), len(tB))
+ }
sort.Sort(gB)
sort.Sort(tB)
+ var out Bookings
for i := 0; i < len(tB); i++ {
if iE := utils.ValidateBooking(gB[i], tB[i]); iE != nil {
log.Printf("ListBookings invalid, %s, abandoning slot %d/%d", iE.Error(), i, len(tB))
@@ -304,7 +307,7 @@
}
out = append(out, tB[i])
}
-
+ log.Printf("ListBookings returning %d bookings", len(out))
return out, nil
}