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

Function TestGetTransaction_NotFound

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

Source from the content-addressed store, hash-verified

186}
187
188func 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
210func TestTransactionExistsByRef_Success(t *testing.T) {
211 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 4

GetTransactionMethod · 0.95
CloseMethod · 0.45
StartMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected