(t *testing.T)
| 1448 | } |
| 1449 | |
| 1450 | func TestIsTransactionRefunded_Error(t *testing.T) { |
| 1451 | db, mock, err := sqlmock.New() |
| 1452 | assert.NoError(t, err) |
| 1453 | defer func() { _ = db.Close() }() |
| 1454 | |
| 1455 | ds := Datasource{Conn: db} |
| 1456 | ctx := context.Background() |
| 1457 | |
| 1458 | txn := &model.Transaction{ |
| 1459 | TransactionID: "txn_123", |
| 1460 | Source: "bln_source", |
| 1461 | Destination: "bln_dest", |
| 1462 | } |
| 1463 | |
| 1464 | mock.ExpectQuery("SELECT EXISTS"). |
| 1465 | WithArgs(txn.TransactionID, txn.Destination, txn.Source). |
| 1466 | WillReturnError(errors.New("database error")) |
| 1467 | |
| 1468 | isRefunded, err := ds.IsTransactionRefunded(ctx, txn) |
| 1469 | assert.Error(t, err) |
| 1470 | assert.False(t, isRefunded) |
| 1471 | apiErr, ok := err.(apierror.APIError) |
| 1472 | assert.True(t, ok) |
| 1473 | assert.Equal(t, apierror.ErrInternalServer, apiErr.Code) |
| 1474 | |
| 1475 | err = mock.ExpectationsWereMet() |
| 1476 | assert.NoError(t, err) |
| 1477 | } |
| 1478 | |
| 1479 | func TestGroupTransactions_InvalidCriteria(t *testing.T) { |
| 1480 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected