(t *testing.T)
| 491 | } |
| 492 | |
| 493 | func TestGetBalanceByIndicator(t *testing.T) { |
| 494 | // Skip in short mode |
| 495 | if testing.Short() { |
| 496 | t.Skip("Skipping real service test in short mode") |
| 497 | } |
| 498 | |
| 499 | ctx := context.Background() |
| 500 | cnf := &config.Configuration{ |
| 501 | Redis: config.RedisConfig{ |
| 502 | Dns: "localhost:6379", |
| 503 | }, |
| 504 | DataSource: config.DataSourceConfig{ |
| 505 | Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable", |
| 506 | }, |
| 507 | Queue: config.QueueConfig{ |
| 508 | WebhookQueue: "webhook_queue_test", |
| 509 | IndexQueue: "index_queue_test", |
| 510 | TransactionQueue: "transaction_queue_test", |
| 511 | NumberOfQueues: 1, |
| 512 | }, |
| 513 | Server: config.ServerConfig{ |
| 514 | SecretKey: "test-secret", |
| 515 | }, |
| 516 | Transaction: config.TransactionConfig{ |
| 517 | BatchSize: 100, |
| 518 | MaxQueueSize: 1000, |
| 519 | LockDuration: time.Second * 30, |
| 520 | IndexQueuePrefix: "test_index", |
| 521 | }, |
| 522 | } |
| 523 | config.ConfigStore.Store(cnf) |
| 524 | |
| 525 | ds, err := database.NewDataSource(cnf) |
| 526 | require.NoError(t, err, "Failed to create datasource") |
| 527 | |
| 528 | ledgerforge, err := NewLedgerForge(ds) |
| 529 | require.NoError(t, err, "Failed to create LedgerForge instance") |
| 530 | |
| 531 | // Generate unique indicator and currency |
| 532 | indicator := "@" + model.GenerateUUIDWithSuffix("test") |
| 533 | currency := "USD" |
| 534 | ledgerID := "general_ledger_id" |
| 535 | |
| 536 | // 1. Create the balance |
| 537 | balanceToCreate := model.Balance{ |
| 538 | Indicator: indicator, |
| 539 | Currency: currency, |
| 540 | LedgerID: ledgerID, |
| 541 | } |
| 542 | |
| 543 | createdBalance, err := ledgerforge.CreateBalance(ctx, balanceToCreate) |
| 544 | require.NoError(t, err, "Failed to create balance") |
| 545 | require.NotEmpty(t, createdBalance.BalanceID, "Created balance should have an ID") |
| 546 | require.Equal(t, indicator, createdBalance.Indicator, "Created balance indicator mismatch") |
| 547 | require.Equal(t, currency, createdBalance.Currency, "Created balance currency mismatch") |
| 548 | |
| 549 | // 2. Get the balance by indicator |
| 550 | retrievedBalance, err := ledgerforge.GetBalanceByIndicator(ctx, indicator, currency) |
nothing calls this directly
no test coverage detected