(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestGetReconciliation_Success(t *testing.T) { |
| 118 | db, mock, err := sqlmock.New() |
| 119 | assert.NoError(t, err) |
| 120 | defer func() { _ = db.Close() }() |
| 121 | completedAt := time.Now() |
| 122 | ds := Datasource{Conn: db} |
| 123 | ctx := context.TODO() |
| 124 | |
| 125 | expectedRec := &model.Reconciliation{ |
| 126 | ID: 1, |
| 127 | ReconciliationID: "rec123", |
| 128 | UploadID: "upl123", |
| 129 | Status: "completed", |
| 130 | MatchedTransactions: 10, |
| 131 | UnmatchedTransactions: 5, |
| 132 | StartedAt: time.Now(), |
| 133 | CompletedAt: &completedAt, |
| 134 | } |
| 135 | |
| 136 | mock.ExpectQuery("SELECT id, reconciliation_id, upload_id, status"). |
| 137 | WithArgs("rec123"). |
| 138 | WillReturnRows(sqlmock.NewRows([]string{ |
| 139 | "id", "reconciliation_id", "upload_id", "status", "matched_transactions", "unmatched_transactions", "started_at", "completed_at", |
| 140 | }).AddRow(expectedRec.ID, expectedRec.ReconciliationID, expectedRec.UploadID, expectedRec.Status, expectedRec.MatchedTransactions, |
| 141 | expectedRec.UnmatchedTransactions, expectedRec.StartedAt, expectedRec.CompletedAt)) |
| 142 | |
| 143 | rec, err := ds.GetReconciliation(ctx, "rec123") |
| 144 | assert.NoError(t, err) |
| 145 | assert.Equal(t, expectedRec.ReconciliationID, rec.ReconciliationID) |
| 146 | } |
| 147 | |
| 148 | func TestGetReconciliation_NotFound(t *testing.T) { |
| 149 | db, mock, err := sqlmock.New() |
nothing calls this directly
no test coverage detected