(t *testing.T)
| 186 | } |
| 187 | |
| 188 | func TestGetTransaction_NotFound(t *testing.T) { |
| 189 | db, mock, err := sqlmock.New() |
| 190 | assert.NoError(t, err) |
| 191 | defer func() { _ = db.Close() }() |
| 192 | |
| 193 | tracer := otel.Tracer("transaction.database") |
| 194 | ctx, span := tracer.Start(context.Background(), "TestGetTransactionNotFound") |
| 195 | defer span.End() |
| 196 | |
| 197 | ds := Datasource{Conn: db} |
| 198 | |
| 199 | mock.ExpectQuery("SELECT transaction_id, source, reference, amount, precise_amount, precision, currency, destination, description, status, created_at, meta_data, parent_transaction, hash FROM ledgerforge.transactions WHERE transaction_id = ?"). |
| 200 | WithArgs("txn123"). |
| 201 | WillReturnError(sql.ErrNoRows) |
| 202 | |
| 203 | _, err = ds.GetTransaction(ctx, "txn123") |
| 204 | assert.Error(t, err) |
| 205 | apiErr, ok := err.(apierror.APIError) |
| 206 | assert.True(t, ok) |
| 207 | assert.Equal(t, apierror.ErrNotFound, apiErr.Code) |
| 208 | } |
| 209 | |
| 210 | func TestTransactionExistsByRef_Success(t *testing.T) { |
| 211 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected