testutils

package
v1.0.0-beta.234 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	AccountService   ledgeraccount.Service
	ResolversService *resolvers.AccountResolver
	HistoricalLedger *historical.Ledger
}

func InitDeps

func InitDeps(db *entdb.Client, logger *slog.Logger) (Deps, error)

type IntegrationEnv

type IntegrationEnv struct {
	Namespace  string
	CustomerID customer.CustomerID
	Currency   currencyx.Code
	// CustomCurrency overrides the resolved custom currency used by routes.
	// Tests that only set Currency get a deterministic definition by default.
	CustomCurrency   *currencies.Currency
	DB               *entdb.Client
	CustomerAccounts ledger.CustomerAccounts
	BusinessAccounts ledger.BusinessAccounts
	Deps             Deps
}

func NewIntegrationEnv

func NewIntegrationEnv(t *testing.T, namespacePrefix string) *IntegrationEnv

func (*IntegrationEnv) AccruedSubAccount

func (e *IntegrationEnv) AccruedSubAccount(t *testing.T) ledger.SubAccount

func (*IntegrationEnv) AccruedSubAccountForCurrency

func (e *IntegrationEnv) AccruedSubAccountForCurrency(t *testing.T, currency currencies.CurrencyReference, costBasisCurrency *currencyx.Code, costBasis *alpacadecimal.Decimal, taxCode *string) ledger.SubAccount

AccruedSubAccountForCurrency is the explicit-currency counterpart of AccruedSubAccountWithCostBasisAndTaxCode.

func (*IntegrationEnv) AccruedSubAccountWithCostBasis

func (e *IntegrationEnv) AccruedSubAccountWithCostBasis(t *testing.T, costBasis *alpacadecimal.Decimal) ledger.SubAccount

func (*IntegrationEnv) AccruedSubAccountWithCostBasisAndTaxCode

func (e *IntegrationEnv) AccruedSubAccountWithCostBasisAndTaxCode(t *testing.T, costBasis *alpacadecimal.Decimal, taxCode *string) ledger.SubAccount

func (*IntegrationEnv) BreakageSubAccountWithCostBasis

func (e *IntegrationEnv) BreakageSubAccountWithCostBasis(t *testing.T, costBasis *alpacadecimal.Decimal) ledger.SubAccount

func (*IntegrationEnv) BrokerageSubAccount

func (e *IntegrationEnv) BrokerageSubAccount(t *testing.T) ledger.SubAccount

func (*IntegrationEnv) BrokerageSubAccountForCurrency

func (e *IntegrationEnv) BrokerageSubAccountForCurrency(t *testing.T, currency currencies.CurrencyReference, costBasisCurrency *currencyx.Code, costBasis alpacadecimal.Decimal) ledger.SubAccount

BrokerageSubAccountForCurrency is the explicit-currency counterpart of BrokerageSubAccount. Passing a nil costBasisCurrency serves a fiat brokerage route; passing the fiat cost-basis currency alongside a custom currency reference serves that custom currency's brokerage route.

func (*IntegrationEnv) CurrencyReference

func (e *IntegrationEnv) CurrencyReference() currencies.CurrencyReference

func (*IntegrationEnv) CustomCurrencyForRoute

func (e *IntegrationEnv) CustomCurrencyForRoute(currency currencyx.Code) currencies.CurrencyReference

func (*IntegrationEnv) EarningsSubAccount

func (e *IntegrationEnv) EarningsSubAccount(t *testing.T) ledger.SubAccount

func (*IntegrationEnv) EarningsSubAccountWithCostBasis

func (e *IntegrationEnv) EarningsSubAccountWithCostBasis(t *testing.T, costBasis *alpacadecimal.Decimal) ledger.SubAccount

func (*IntegrationEnv) EarningsSubAccountWithCostBasisAndTaxCode

func (e *IntegrationEnv) EarningsSubAccountWithCostBasisAndTaxCode(t *testing.T, costBasis *alpacadecimal.Decimal, taxCode *string) ledger.SubAccount

func (*IntegrationEnv) EntriesForSubAccount

func (e *IntegrationEnv) EntriesForSubAccount(entries []*entdb.LedgerEntry, subAccount ledger.SubAccount) []*entdb.LedgerEntry

EntriesForSubAccount filters a set of ledger entries down to the ones posted against a specific sub-account.

func (*IntegrationEnv) FBOSubAccount

func (e *IntegrationEnv) FBOSubAccount(t *testing.T, priority int) ledger.SubAccount

func (*IntegrationEnv) FBOSubAccountForCurrency

func (e *IntegrationEnv) FBOSubAccountForCurrency(t *testing.T, currency currencies.CurrencyReference, costBasisCurrency *currencyx.Code, costBasis alpacadecimal.Decimal) ledger.SubAccount

FBOSubAccountForCurrency is the explicit-currency counterpart of FBOSubAccount, for tests that operate on a currency other than the env's own (e.g. a custom currency alongside its fiat cost-basis currency).

func (*IntegrationEnv) Now

func (e *IntegrationEnv) Now() time.Time

func (*IntegrationEnv) ReceivableSubAccount

func (e *IntegrationEnv) ReceivableSubAccount(t *testing.T) ledger.SubAccount

func (*IntegrationEnv) ReceivableSubAccountForCurrency

func (e *IntegrationEnv) ReceivableSubAccountForCurrency(t *testing.T, currency currencies.CurrencyReference, costBasisCurrency *currencyx.Code, costBasis alpacadecimal.Decimal) ledger.SubAccount

ReceivableSubAccountForCurrency is the explicit-currency, open-status counterpart of ReceivableSubAccountWithCostBasis.

func (*IntegrationEnv) ReceivableSubAccountWithCostBasis

func (e *IntegrationEnv) ReceivableSubAccountWithCostBasis(t *testing.T, costBasis *alpacadecimal.Decimal) ledger.SubAccount

func (*IntegrationEnv) ReceivableSubAccountWithCostBasisAndStatus

func (e *IntegrationEnv) ReceivableSubAccountWithCostBasisAndStatus(t *testing.T, costBasis *alpacadecimal.Decimal, status ledger.TransactionAuthorizationStatus) ledger.SubAccount

func (*IntegrationEnv) ReceivableSubAccountWithStatus

func (e *IntegrationEnv) ReceivableSubAccountWithStatus(t *testing.T, status ledger.TransactionAuthorizationStatus) ledger.SubAccount

func (*IntegrationEnv) SumBalance

func (e *IntegrationEnv) SumBalance(t *testing.T, subAccount ledger.SubAccount) alpacadecimal.Decimal

func (*IntegrationEnv) TransactionGroupEntries

func (e *IntegrationEnv) TransactionGroupEntries(t *testing.T, groupID string) []*entdb.LedgerEntry

TransactionGroupEntries returns every ledger entry posted by the transactions in a committed group, ordered by creation.

func (*IntegrationEnv) WashSubAccount

func (e *IntegrationEnv) WashSubAccount(t *testing.T) ledger.SubAccount

func (*IntegrationEnv) WashSubAccountWithCostBasis

func (e *IntegrationEnv) WashSubAccountWithCostBasis(t *testing.T, costBasis *alpacadecimal.Decimal) ledger.SubAccount

type LineageWithAllocations

type LineageWithAllocations struct {
	legacylineage.Service
	// contains filtered or unexported fields
}

LineageWithAllocations retains the allocation references supplied by direct ledger/handler tests, which do not persist charge runs. Lineage state itself still uses the real database-backed service. Full lifecycle tests load these references from the charge allocation tables.

func (*LineageWithAllocations) CreateInitialLineages

func (*LineageWithAllocations) LoadLineagesByCustomer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL