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

Function TestGetBalanceByIndicator_NotFound

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

Source from the content-addressed store, hash-verified

954}
955
956func TestGetBalanceByIndicator_NotFound(t *testing.T) {
957 db, mock, err := sqlmock.New()
958 assert.NoError(t, err)
959 defer func() { _ = db.Close() }()
960
961 ds := Datasource{Conn: db}
962
963 query := `
964 SELECT balance_id, indicator, currency, currency_multiplier, ledger_id, balance, credit_balance, debit_balance, inflight_balance, inflight_credit_balance, inflight_debit_balance, created_at, version, track_fund_lineage, COALESCE(allocation_strategy, 'FIFO') as allocation_strategy, COALESCE(identity_id, '') as identity_id
965 FROM ledgerforge.balances
966 WHERE indicator = $1 AND currency = $2
967 `
968
969 mock.ExpectQuery(regexp.QuoteMeta(query)).
970 WithArgs("NONEXISTENT", "USD").
971 WillReturnError(sql.ErrNoRows)
972
973 balance, err := ds.GetBalanceByIndicator("NONEXISTENT", "USD")
974 assert.Error(t, err)
975 assert.NotNil(t, balance)
976 assert.Equal(t, "", balance.BalanceID)
977 assert.Contains(t, err.Error(), "not found")
978
979 err = mock.ExpectationsWereMet()
980 assert.NoError(t, err)
981}
982
983func TestGetAllBalances_Success(t *testing.T) {
984 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

GetBalanceByIndicatorMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected