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

Function TestRecordMatch_Error

database/reconciliation_test.go:409–432  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

407}
408
409func TestRecordMatch_Error(t *testing.T) {
410 db, mock, err := sqlmock.New()
411 assert.NoError(t, err)
412 defer func() { _ = db.Close() }()
413
414 ds := Datasource{Conn: db}
415 ctx := context.TODO()
416
417 match := &model.Match{
418 ExternalTransactionID: "ext1",
419 InternalTransactionID: "int1",
420 ReconciliationID: "rec123",
421 Amount: 1000,
422 Date: time.Now(),
423 }
424
425 mock.ExpectExec("INSERT INTO ledgerforge.matches").
426 WithArgs(match.ExternalTransactionID, match.InternalTransactionID, match.ReconciliationID, match.Amount, match.Date).
427 WillReturnError(fmt.Errorf("insert error"))
428
429 err = ds.RecordMatch(ctx, match)
430 assert.Error(t, err)
431 assert.Equal(t, apierror.ErrInternalServer, err.(apierror.APIError).Code)
432}
433
434func TestGetMatchesByReconciliationID_Success(t *testing.T) {
435 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

RecordMatchMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected