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

Function TestRecordMatches_Fail

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

Source from the content-addressed store, hash-verified

252}
253
254func TestRecordMatches_Fail(t *testing.T) {
255 db, mock, err := sqlmock.New()
256 assert.NoError(t, err)
257 defer func() { _ = db.Close() }()
258
259 ds := Datasource{Conn: db}
260 ctx := context.TODO()
261
262 matches := []model.Match{
263 {
264 ExternalTransactionID: "ext1",
265 InternalTransactionID: "int1",
266 ReconciliationID: "rec123",
267 Amount: 1000,
268 Date: time.Now(),
269 },
270 }
271
272 mock.ExpectBegin()
273 mock.ExpectExec("INSERT INTO ledgerforge.matches").
274 WithArgs(matches[0].ExternalTransactionID, matches[0].InternalTransactionID, matches[0].ReconciliationID, matches[0].Amount, matches[0].Date).
275 WillReturnError(fmt.Errorf("failed to insert match"))
276 mock.ExpectRollback()
277
278 err = ds.RecordMatches(ctx, "rec123", matches)
279 assert.Error(t, err)
280 assert.Equal(t, apierror.ErrInternalServer, err.(apierror.APIError).Code)
281}
282
283func TestGetReconciliationsByUploadID_Success(t *testing.T) {
284 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

RecordMatchesMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected