(t *testing.T)
| 954 | } |
| 955 | |
| 956 | func 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 | |
| 983 | func TestGetAllBalances_Success(t *testing.T) { |
| 984 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected