improve robustness and add unit tests

This commit is contained in:
MaysWind
2024-11-17 23:23:23 +08:00
parent a4b26374f4
commit ec0cb0bbb7
8 changed files with 66 additions and 1 deletions
@@ -112,6 +112,11 @@ func (e *BankOfIsraelExchangeRate) ToLatestExchangeRate(c core.Context) *models.
return nil
}
if unit <= 0 {
log.Warnf(c, "[bank_of_israel_datasource.ToLatestExchangeRate] unit is less or equal zero, currency is %s, unit is %s", e.Currency, e.Unit)
return nil
}
finalRate := unit / rate
if math.IsInf(finalRate, 0) {