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
@@ -134,6 +134,11 @@ func (e *CentralBankOfHungaryExchangeRate) ToLatestExchangeRate(c core.Context)
return nil
}
if unit <= 0 {
log.Warnf(c, "[central_bank_of_hungary_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) {