修复钱包金额精度结算
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
)
|
||||
|
||||
func TestApplyEntryRoundsMoneyBeforeComparing(t *testing.T) {
|
||||
account := model.WalletAccount{
|
||||
UserID: 7,
|
||||
FrozenBalance: 606.41,
|
||||
}
|
||||
entry := Entry{
|
||||
UserID: 7,
|
||||
Direction: "out",
|
||||
Amount: 406.41 + 200.00,
|
||||
BalanceType: "frozen",
|
||||
}
|
||||
|
||||
balanceAfter, err := applyEntry(&account, entry)
|
||||
if err != nil {
|
||||
t.Fatalf("applyEntry() error = %v", err)
|
||||
}
|
||||
if balanceAfter != 0 {
|
||||
t.Fatalf("balanceAfter = %v, want 0", balanceAfter)
|
||||
}
|
||||
if account.FrozenBalance != 0 {
|
||||
t.Fatalf("FrozenBalance = %v, want 0", account.FrozenBalance)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user