(t *testing.T)
| 407 | } |
| 408 | |
| 409 | func 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 | |
| 434 | func TestGetMatchesByReconciliationID_Success(t *testing.T) { |
| 435 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected