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
@@ -144,6 +144,9 @@ func (e *NorgesBankExchangeRate) ToLatestExchangeRate(c core.Context, exchangeRa
if unitExponent > 0 {
finalRate = finalRate / math.Pow10(-unitExponent)
} else if unitExponent < 0 {
log.Warnf(c, "[norges_bank_datasource.ToLatestExchangeRate] unit exponent is less than zero, currency is %s, unit is %s", e.BaseCurrency, e.UnitExponent)
return nil
}
if math.IsInf(finalRate, 0) {