MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestApplyTransaction_InvalidAmount

Function TestApplyTransaction_InvalidAmount

database/balance_test.go:2090–2114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2088}
2089
2090func TestApplyTransaction_InvalidAmount(t *testing.T) {
2091 balanceID := "bln_test123"
2092 creditBalance := big.NewInt(1000)
2093 debitBalance := big.NewInt(500)
2094
2095 txn := struct {
2096 PreciseAmount string
2097 Source string
2098 Destination string
2099 CreatedAt time.Time
2100 EffectiveDate time.Time
2101 }{
2102 PreciseAmount: "invalid_amount",
2103 Source: balanceID,
2104 Destination: "other_balance",
2105 CreatedAt: time.Now(),
2106 EffectiveDate: time.Now(),
2107 }
2108
2109 _, _, err := applyTransaction(txn, balanceID, creditBalance, debitBalance)
2110 assert.Error(t, err)
2111 apiErr, ok := err.(apierror.APIError)
2112 assert.True(t, ok)
2113 assert.Equal(t, apierror.ErrInternalServer, apiErr.Code)
2114}
2115
2116func TestCalculateBalanceFromTransactions_Success(t *testing.T) {
2117 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 2

applyTransactionFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected