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

Function TestRecordMatches_Success

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

Source from the content-addressed store, hash-verified

213}
214
215func TestRecordMatches_Success(t *testing.T) {
216 db, mock, err := sqlmock.New()
217 assert.NoError(t, err)
218 defer func() { _ = db.Close() }()
219
220 ds := Datasource{Conn: db}
221 ctx := context.TODO()
222
223 matches := []model.Match{
224 {
225 ExternalTransactionID: "ext1",
226 InternalTransactionID: "int1",
227 ReconciliationID: "rec123",
228 Amount: 1000,
229 Date: time.Now(),
230 },
231 {
232 ExternalTransactionID: "ext2",
233 InternalTransactionID: "int2",
234 ReconciliationID: "rec123",
235 Amount: 2000,
236 Date: time.Now(),
237 },
238 }
239
240 mock.ExpectBegin()
241
242 for _, match := range matches {
243 mock.ExpectExec("INSERT INTO ledgerforge.matches").
244 WithArgs(match.ExternalTransactionID, match.InternalTransactionID, match.ReconciliationID, match.Amount, match.Date).
245 WillReturnResult(sqlmock.NewResult(1, 1))
246 }
247
248 mock.ExpectCommit()
249
250 err = ds.RecordMatches(ctx, "rec123", matches)
251 assert.NoError(t, err)
252}
253
254func TestRecordMatches_Fail(t *testing.T) {
255 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 2

RecordMatchesMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected