checkUpdates checks that updates show steady progress toward a total, and don't describe errors.
(updates <-chan v1.Update)
| 430 | // checkUpdates checks that updates show steady progress toward a total, and |
| 431 | // don't describe errors. |
| 432 | func checkUpdates(updates <-chan v1.Update) error { |
| 433 | var high, total int64 |
| 434 | for u := range updates { |
| 435 | if u.Error != nil { |
| 436 | return u.Error |
| 437 | } |
| 438 | |
| 439 | if u.Total < total { |
| 440 | return fmt.Errorf("total changed: was %d, saw %d", total, u.Total) |
| 441 | } |
| 442 | |
| 443 | total = u.Total |
| 444 | |
| 445 | if u.Complete < high { |
| 446 | return fmt.Errorf("saw progress revert: was high of %d, saw %d", high, u.Complete) |
| 447 | } |
| 448 | high = u.Complete |
| 449 | } |
| 450 | |
| 451 | if high > total { |
| 452 | return fmt.Errorf("final progress (%d) exceeded total (%d) by %d", high, total, high-total) |
| 453 | } else if high < total { |
| 454 | return fmt.Errorf("final progress (%d) did not reach total (%d) by %d", high, total, total-high) |
| 455 | } |
| 456 | |
| 457 | return nil |
| 458 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…