mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 08:27:46 +08:00
test(postgres): decode ledger amount as float8
This commit is contained in:
@@ -9641,8 +9641,9 @@ mod tests {
|
|||||||
assert_eq!(transaction.balance_before, 13.0);
|
assert_eq!(transaction.balance_before, 13.0);
|
||||||
assert_eq!(transaction.balance_after, 0.0);
|
assert_eq!(transaction.balance_after, 0.0);
|
||||||
assert_eq!(wallet.balance + wallet.gift_balance, 0.0);
|
assert_eq!(wallet.balance + wallet.gift_balance, 0.0);
|
||||||
let persisted_amount: f64 =
|
let persisted_amount: f64 = sqlx::query_scalar(
|
||||||
sqlx::query_scalar("SELECT amount FROM wallet_transactions WHERE id = $1")
|
"SELECT amount::double precision FROM wallet_transactions WHERE id = $1",
|
||||||
|
)
|
||||||
.bind(&transaction.id)
|
.bind(&transaction.id)
|
||||||
.fetch_one(&pool)
|
.fetch_one(&pool)
|
||||||
.await
|
.await
|
||||||
@@ -9698,6 +9699,14 @@ mod tests {
|
|||||||
assert_eq!(transaction.amount, 1.0);
|
assert_eq!(transaction.amount, 1.0);
|
||||||
assert_eq!(transaction.balance_before, -1.0);
|
assert_eq!(transaction.balance_before, -1.0);
|
||||||
assert_eq!(transaction.balance_after, 0.0);
|
assert_eq!(transaction.balance_after, 0.0);
|
||||||
|
let persisted_correction_amount: f64 = sqlx::query_scalar(
|
||||||
|
"SELECT amount::double precision FROM wallet_transactions WHERE id = $1",
|
||||||
|
)
|
||||||
|
.bind(&transaction.id)
|
||||||
|
.fetch_one(&pool)
|
||||||
|
.await
|
||||||
|
.expect("ledger should store the negative-balance correction");
|
||||||
|
assert_eq!(persisted_correction_amount, 1.0);
|
||||||
let transaction_count: i64 =
|
let transaction_count: i64 =
|
||||||
sqlx::query_scalar("SELECT COUNT(*) FROM wallet_transactions WHERE wallet_id = $1")
|
sqlx::query_scalar("SELECT COUNT(*) FROM wallet_transactions WHERE wallet_id = $1")
|
||||||
.bind(&wallet_id)
|
.bind(&wallet_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user