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

Function TestLineageAllocationStrategies

lineage_integration_test.go:566–865  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

564}
565
566func TestLineageAllocationStrategies(t *testing.T) {
567 if testing.Short() {
568 t.Skip("Skipping lineage integration test in short mode")
569 }
570
571 ctx := context.Background()
572 pollInterval := 200 * time.Millisecond
573 pollTimeout := 15 * time.Second
574
575 cnf := &config.Configuration{
576 Redis: config.RedisConfig{
577 Dns: "localhost:6379",
578 },
579 DataSource: config.DataSourceConfig{
580 Dns: "postgres://postgres:password@localhost:5432/ledgerforge?sslmode=disable",
581 },
582 Queue: config.QueueConfig{
583 WebhookQueue: "webhook_queue_test",
584 IndexQueue: "index_queue_test",
585 TransactionQueue: "transaction_queue_test",
586 NumberOfQueues: 1,
587 },
588 Server: config.ServerConfig{
589 SecretKey: "test-secret",
590 },
591 Transaction: config.TransactionConfig{
592 BatchSize: 100,
593 MaxQueueSize: 1000,
594 LockDuration: time.Second * 30,
595 IndexQueuePrefix: "test_index",
596 },
597 }
598 config.ConfigStore.Store(cnf)
599
600 ds, err := database.NewDataSource(cnf)
601 require.NoError(t, err, "Failed to create datasource")
602
603 ledgerforge, err := NewLedgerForge(ds)
604 require.NoError(t, err, "Failed to create LedgerForge instance")
605
606 // Start the lineage outbox processor to process lineage entries asynchronously
607 processor := NewLineageOutboxProcessor(ledgerforge).WithPollInterval(100 * time.Millisecond)
608 processor.Start(ctx)
609 defer processor.Stop()
610
611 suffix := fmt.Sprintf("%d", time.Now().UnixNano())
612
613 t.Run("LIFO Allocation", func(t *testing.T) {
614 identity, err := ds.CreateIdentity(model.Identity{
615 FirstName: fmt.Sprintf("LIFO_%s", suffix),
616 LastName: "User",
617 Category: "individual",
618 })
619 require.NoError(t, err)
620
621 balance, err := ds.CreateBalance(model.Balance{
622 Currency: "USD",
623 LedgerID: GeneralLedgerID,

Callers

nothing calls this directly

Calls 13

QueueTransactionMethod · 0.95
GetBalanceLineageMethod · 0.95
NewDataSourceFunction · 0.92
NewLedgerForgeFunction · 0.85
pollForLineageMappingsFunction · 0.85
pollForBalanceFunction · 0.85
WithPollIntervalMethod · 0.80
CreateIdentityMethod · 0.65
CreateBalanceMethod · 0.65
StartMethod · 0.45

Tested by

no test coverage detected