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

Function TestIsTransactionRefunded_Error

database/transactions_test.go:1450–1477  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1448}
1449
1450func 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
1479func TestGroupTransactions_InvalidCriteria(t *testing.T) {
1480 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

IsTransactionRefundedMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected