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

Function TestFindMappingByShadowID

lineage_test.go:409–466  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

407}
408
409func TestFindMappingByShadowID(t *testing.T) {
410 datasource, _, err := newTestDataSource()
411 if err != nil {
412 t.Fatalf("Error creating test data source: %s", err)
413 }
414
415 ledgerforge, err := NewLedgerForge(datasource)
416 if err != nil {
417 t.Fatalf("Error creating LedgerForge instance: %s", err)
418 }
419
420 mappings := []model.LineageMapping{
421 {
422 ID: 1,
423 BalanceID: "bln_main",
424 Provider: "stripe",
425 ShadowBalanceID: "bln_stripe_shadow",
426 },
427 {
428 ID: 2,
429 BalanceID: "bln_main",
430 Provider: "paypal",
431 ShadowBalanceID: "bln_paypal_shadow",
432 },
433 }
434
435 tests := []struct {
436 name string
437 shadowBalanceID string
438 expectFound bool
439 expectedProvider string
440 }{
441 {
442 name: "Find existing shadow",
443 shadowBalanceID: "bln_stripe_shadow",
444 expectFound: true,
445 expectedProvider: "stripe",
446 },
447 {
448 name: "Shadow not found",
449 shadowBalanceID: "bln_nonexistent",
450 expectFound: false,
451 },
452 }
453
454 for _, tt := range tests {
455 t.Run(tt.name, func(t *testing.T) {
456 result := ledgerforge.findMappingByShadowID(mappings, tt.shadowBalanceID)
457
458 if tt.expectFound {
459 assert.NotNil(t, result)
460 assert.Equal(t, tt.expectedProvider, result.Provider)
461 } else {
462 assert.Nil(t, result)
463 }
464 })
465 }
466}

Callers

nothing calls this directly

Calls 3

findMappingByShadowIDMethod · 0.95
newTestDataSourceFunction · 0.85
NewLedgerForgeFunction · 0.85

Tested by

no test coverage detected