(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestRecordReconciliation_Success(t *testing.T) { |
| 60 | db, mock, err := sqlmock.New() |
| 61 | assert.NoError(t, err) |
| 62 | defer func() { _ = db.Close() }() |
| 63 | |
| 64 | ds := Datasource{Conn: db} |
| 65 | ctx := context.TODO() |
| 66 | completedAt := time.Now() |
| 67 | |
| 68 | rec := &model.Reconciliation{ |
| 69 | ReconciliationID: "rec123", |
| 70 | UploadID: "upl123", |
| 71 | Status: "completed", |
| 72 | MatchedTransactions: 10, |
| 73 | UnmatchedTransactions: 5, |
| 74 | StartedAt: time.Now(), |
| 75 | CompletedAt: &completedAt, |
| 76 | } |
| 77 | |
| 78 | mock.ExpectExec("INSERT INTO ledgerforge.reconciliations"). |
| 79 | WithArgs(rec.ReconciliationID, rec.UploadID, rec.Status, rec.MatchedTransactions, |
| 80 | rec.UnmatchedTransactions, rec.StartedAt, rec.CompletedAt). |
| 81 | WillReturnResult(sqlmock.NewResult(1, 1)) |
| 82 | |
| 83 | err = ds.RecordReconciliation(ctx, rec) |
| 84 | assert.NoError(t, err) |
| 85 | } |
| 86 | |
| 87 | func TestRecordReconciliation_Fail(t *testing.T) { |
| 88 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected