(t *testing.T)
| 383 | } |
| 384 | |
| 385 | func TestRecordMatch_Success(t *testing.T) { |
| 386 | db, mock, err := sqlmock.New() |
| 387 | assert.NoError(t, err) |
| 388 | defer func() { _ = db.Close() }() |
| 389 | |
| 390 | ds := Datasource{Conn: db} |
| 391 | ctx := context.TODO() |
| 392 | |
| 393 | match := &model.Match{ |
| 394 | ExternalTransactionID: "ext1", |
| 395 | InternalTransactionID: "int1", |
| 396 | ReconciliationID: "rec123", |
| 397 | Amount: 1000, |
| 398 | Date: time.Now(), |
| 399 | } |
| 400 | |
| 401 | mock.ExpectExec("INSERT INTO ledgerforge.matches"). |
| 402 | WithArgs(match.ExternalTransactionID, match.InternalTransactionID, match.ReconciliationID, match.Amount, match.Date). |
| 403 | WillReturnResult(sqlmock.NewResult(1, 1)) |
| 404 | |
| 405 | err = ds.RecordMatch(ctx, match) |
| 406 | assert.NoError(t, err) |
| 407 | } |
| 408 | |
| 409 | func TestRecordMatch_Error(t *testing.T) { |
| 410 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected