(t *testing.T)
| 6582 | } |
| 6583 | |
| 6584 | func TestGetBalanceByID_Mock(t *testing.T) { |
| 6585 | cnf := &config.Configuration{ |
| 6586 | Redis: config.RedisConfig{Dns: "localhost:6379"}, |
| 6587 | Queue: config.QueueConfig{ |
| 6588 | WebhookQueue: "webhook_queue", |
| 6589 | TransactionQueue: "transaction_queue", |
| 6590 | NumberOfQueues: 1, |
| 6591 | }, |
| 6592 | } |
| 6593 | config.ConfigStore.Store(cnf) |
| 6594 | |
| 6595 | t.Run("Success", func(t *testing.T) { |
| 6596 | mockDS := new(mocks.MockDataSource) |
| 6597 | balanceID := "bln_test_123" |
| 6598 | expectedBalance := &model.Balance{ |
| 6599 | BalanceID: balanceID, |
| 6600 | Currency: "USD", |
| 6601 | Balance: big.NewInt(10000), |
| 6602 | } |
| 6603 | |
| 6604 | mockDS.On("GetBalanceByID", balanceID, []string(nil), false).Return(expectedBalance, nil) |
| 6605 | |
| 6606 | ledgerforge := &LedgerForge{datasource: mockDS, config: cnf} |
| 6607 | result, err := ledgerforge.GetBalanceByID(context.Background(), balanceID, nil, false) |
| 6608 | |
| 6609 | assert.NoError(t, err) |
| 6610 | assert.NotNil(t, result) |
| 6611 | assert.Equal(t, balanceID, result.BalanceID) |
| 6612 | mockDS.AssertExpectations(t) |
| 6613 | }) |
| 6614 | |
| 6615 | t.Run("Not found", func(t *testing.T) { |
| 6616 | mockDS := new(mocks.MockDataSource) |
| 6617 | balanceID := "bln_nonexistent" |
| 6618 | |
| 6619 | mockDS.On("GetBalanceByID", balanceID, []string(nil), false).Return((*model.Balance)(nil), fmt.Errorf("not found")) |
| 6620 | |
| 6621 | ledgerforge := &LedgerForge{datasource: mockDS, config: cnf} |
| 6622 | result, err := ledgerforge.GetBalanceByID(context.Background(), balanceID, nil, false) |
| 6623 | |
| 6624 | assert.Error(t, err) |
| 6625 | assert.Nil(t, result) |
| 6626 | mockDS.AssertExpectations(t) |
| 6627 | }) |
| 6628 | } |
| 6629 | |
| 6630 | func TestGetAllBalances_Mock(t *testing.T) { |
| 6631 | cnf := &config.Configuration{ |
nothing calls this directly
no test coverage detected