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

Function TestReconciliationEdgeCases

reconciliation_test.go:389–478  ·  view source on GitHub ↗

TestReconciliationEdgeCases tests edge cases in the reconciliation process

(t *testing.T)

Source from the content-addressed store, hash-verified

387
388// TestReconciliationEdgeCases tests edge cases in the reconciliation process
389func TestReconciliationEdgeCases(t *testing.T) {
390 cnf := &config.Configuration{
391 Redis: config.RedisConfig{
392 Dns: "localhost:6379",
393 },
394 Transaction: config.TransactionConfig{
395 BatchSize: 100000,
396 MaxWorkers: 1,
397 },
398 Queue: config.QueueConfig{
399 WebhookQueue: "webhook_queue",
400 NumberOfQueues: 1,
401 },
402 Reconciliation: config.ReconciliationConfig{
403 ProgressInterval: 100,
404 },
405 }
406 config.ConfigStore.Store(cnf)
407 mockDS := new(mocks.MockDataSource)
408
409 ledgerforge := &LedgerForge{datasource: mockDS}
410
411 ctx := context.Background()
412
413 t.Run("Empty external transactions", func(t *testing.T) {
414 externalTxns := []*model.Transaction{}
415 matchingRules := []model.MatchingRule{
416 {
417 RuleID: "rule1",
418 Criteria: []model.MatchingCriteria{
419 {Field: "amount", Operator: "equals", AllowableDrift: 0},
420 },
421 },
422 }
423
424 matches, unmatched := ledgerforge.oneToOneReconciliation(ctx, externalTxns, matchingRules)
425
426 assert.Equal(t, 0, len(matches), "Expected 0 matches")
427 assert.Equal(t, 0, len(unmatched), "Expected 0 unmatched transactions")
428 })
429
430 t.Run("No matching internal transactions", func(t *testing.T) {
431 externalTxns := []*model.Transaction{
432 {TransactionID: "ext1", Amount: 100, CreatedAt: time.Now()},
433 }
434
435 mockDS.On("GetTransactionsByCriteria", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, 100000, int64(0)).Return([]*model.Transaction{}, nil).Once()
436
437 matchingRules := []model.MatchingRule{
438 {
439 RuleID: "rule1",
440 Criteria: []model.MatchingCriteria{
441 {Field: "amount", Operator: "equals", AllowableDrift: 0},
442 },
443 },
444 }
445
446 matches, unmatched := ledgerforge.oneToOneReconciliation(ctx, externalTxns, matchingRules)

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected